by
1
3
95
0
Easy-to-find
Specified
OpenSource
Created
Modified Jan 10, 2019
Architecturex86_64
Languagejavascript
Phaser versionv3.15.x

Game Box Prototype

command combinations
Description: Quickly create operational games using simple box graphics from Phaser3 shapes (v3.13.x). This test game mechanics for enjoyment. Final Artwork added to game mechanisms, prototypes and mechanics as the final pipeline product phase.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4243818/Game-Box-Prototype?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// ============ //Example 4.1: Prototyping Graphics begins // ============ //create a character avatar using the box prototype method player = box({who: this, whereX: 150, whereY: 100,length:32, width:32, color: 0x0000FF,border: 0xFFFFFF}); this.physics.add.existing(player); player.body.velocity.x = 10; //see update function player.body.velocity.y = 50; console.log("Stationary Blue character avatar created as 'player' variable."); // ------------ // OR the direct method using either rectangle or graphics // and set movement velocities. var avatar = this.add.rectangle(100, 100, 32, 32, 0x0000FF).setStrokeStyle(5, 0x3399CC); console.log("Moving Blue character avatar created as 'player' variable."); var graphics = this.add.graphics({ fillStyle: { color: 0xFF0000 } }); graphics.lineStyle(10,0xFF9900,0); graphics.strokeRect(100, 100, 32, 32); //non-controlled movement (usage AI bot; see Chapter 6) graphics.fillRectShape(avatar); this.physics.add.existing(avatar); avatar.body.velocity.x = 50; avatar.body.velocity.y = 10; //non-controlled movement (usage AI bot; see Chapter 6) this.physics.add.existing(graphics); graphics.body.velocity.x = 50; graphics.body.velocity.y = 50; console.log("Moving Red avatar created as 'avatar' variable.\n Movement velocity set."); // ------------ //create an opponent - direct method var monster = this.add.rectangle(180, 60, 32, 32, 0x00FF00).setStrokeStyle(5, 0xFF9900); console.log("Green monster avatar created as 'monster' variable."); //Example 4.1: ends // ============
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus