Home
Fusion 2.5+
Firefly+
Tutorials+
Videos+
Guides & Tips+
Extensions
Versions
Teaching


The snowboarder

The snowboarder


Movement


We are going to make our snowboarder move.

 

  1. Click on the "Snowboarder" object to display its properties in the property explorer and select the "Movements" tab.
  2. Open the "Type" combo box, and choose "Bouncing ball".
  3. Click on the "Initial Direction" entry and deselect all the directions by clicking on the "Reset" button and then select the direction facing down. It must be the only one selected.

 

First event


Open the Event Editor by clicking on its icon in the toolbar. Our snowboarder has a ball movement, but he will be controlled by the keyboard.
Let's first set his vertical position with the following event :

  • Always

(snowboarder) : Set Y position to 80

Testing the keyboard


We are going to test the left arrow key and make the player turn to the left when it is pressed. Explanation of the following events:

  • We first test if the left arrow is pressed
  • If it is, then the next condition ensures that the event will be executed every 1/10th of second
  • The third condition makes sure the player is not already facing the left (direction 18) To obtain the negation icon, right click on the condition and choose "Negate"

Once all the condition are satisfied, the actions make the player turn to the left using an expression.

  • Repeat while "Left Arrow" is pressed

+ Every 00"-10

+ X (snowboarder) is facing direction

(snowboarder) Set direction to Dir( " (snowboarder)" ) - 2

Turning to the right


We need to program the same events to make the player turn to the right. Once this event entered, you will be able to test your game by clicking on the "Run frame" icon.

  • Repeat while "Right Arrow" is pressed

+ Every 00"-10

+ X (snowboarder) is facing direction 

(snowboarder) Set direction to Dir( " (snowboarder)" ) + 2

Keeping the player on the slope


Our snowboarder can get out of the play area on the left and on the right, we need to block the movement when he gets close to the edge of the screen.

• X position of  (snowboarder) <= 0

(snowboarder) : Set X position to 0

• X position of (snowboarder) >= 640

(snowboarder) : Set X position to 640




Spread the word!



You can share this document using the following buttons.




Submit your own User Tip