|
- If you are coding outside of WoofJS.com (like in Sublime), insert the Woof_JS source tag into the <head>section of your project page:
<script src="https://rawgit.com/stevekrouse/WoofJS/master/dist/woof.js"></script>
Your code now speaks Woof!
- Select a background appropriate for your game. Create a Lander with an image you like.
- Setup variables for:
* downSpeed
* sideSpeed
* downThrust
* gravity
- Add a forever loop. In the loop, move the rocket by downSpeed and sideSpeed.
- If a key is pressed, increase downThrust otherwise make downThrust zero. Adjust downSpeed by downThrust and gravity.
- You might notice that its hard to play-balance the game, to make the lander change speed smoothly. Add variables for speedDamper, thrustDamper and gravityDamper and use these when you calculate speed:
lander.y = lander.y - downSpeed/speedDamper;
Change these till the lander is flying smoothly.
- Add text labels to show downThrust and downSpeed. Adjust these so they are human-readable integers (numbers without decimals. Also add a label to show status messages, i.e. “You Landed!”
- Check if the lander has hit the bottom of the screen, and if the speed is too great, show a crash, with an appropriate graphic. If the speed is good, congratulate the player on a good landing.
- Create your landing terrain. One way to do this is to use a for-loop, and create as many mountain rectangles as you need to fill the screen. Use random numbers to vary the width of each rectangle and also how far the top of each rectangle is away from the previous one. Make sure to add each rectangle to an array.
- If the width of that rectangles is above the minimum needed to be a landing pad, add a yellow line indicating its safe to land there.
- As the lander is flying, cycle through all the rectangles and check if the lander is touching any of them. Use the code you had from before to check if the landing speed is safe, and if its a crash or a landing.
- Test and finish the project till it looks perfect to you.
|
|