Go back Home

Hi, this is my first project walkthrough. Any feedback would be appreciated

Creating a 2D Sprite Game

NOTE: Whenever I use 'stack' in this document, I am referring to a block of commands. Sidebar is a section where you don't have to do anything, just read and understand

Delete any sprites on screen

Create new sprite (Choose upload from file)

Navigate to flash sprites folder

Select the image named TheFlash_r1_c3

Add the following block IdleStack

We want our sprite to instantiate at the left edge of the screen, so add the following to your code

go to x:-193, y-123

Adding an Idle pose for our character

Go to costumes

Upload costume from file

Go back to your images folder and select r1_c9, hold ctrl and also select r1_c14 and r1_c20. Click open

Go back to scripts

Add the following stack to your code

IdleStack

Add block BroadcastIdle to IdleStack

Moving Right

In costumes, Upload TheFlash_r1_c27, r1_c34 and r1_c30

Go back to Scripts.

From events, add the block "When right arrow key pressed"

Now, we are going to animate the right move the same way we did the Idle stack. Notice the wait time of 0.167 secs. We don't want to change the value in every single wait block every time we want to change the feel of our game so we shall create two variables.

Go to Data, click "Make a Variable" and create one called "fps" and one called "period".

Sidebar: FPS & Period

FPS is an animation term that means Frames per Second. Simply put, it is the number of sprites in one second of animation, the higher the fps the faster the game feels. Consequently, the lower the fps the slower it feels. The period is simply 1 divided by the fps and is the actual wait time

Add this to your first block

FPSPeriod

Now make a "Right Move block" that looks like this

RightMove

Try playing your game now.
Why does the character not return to the "Idle" pose? See if you can solve this

Also, replace the IdleStack in your "Idle" stack with IdleStack

Now, change the value of IdleStackfps.PNG. Try using 15, 30 and 60. How does it affect the game?

Moving Left

Go to costumes and duplicate r1_c27

Duplicate

Look for the select tool in the Editor and click it SelectToolselecttool.PNG

Select the sprite, It should look like this

SelectSprite

Select flip leftright

IdleStack

Now do the same for r1_c34 and r1_c40 (Duplicate and Flip)



From the knowledge you gained so far, try to program the stack for moving left using the three new costumes