Le Tortue fou (The crazy Tortoise)
See the Pen Crazy Tortoise [http://codepen.io/khanhhua/pen/pJWMzX/] by Khanh Hua (@khanhhua [http://codepen.io/khanhhua]) on CodePen [http://codepen.io].
I would like to share a pen I made in June. It is a simple console looking game to demonstrate various aspects of creating a game for browsers. Please give it a try here http://codepen.io/khanhhua/full/pJWMzX/ In the following section, I would like to give the details of the game from ideas to implementations, from problems to solutions.
Version 1 (June 23rd 2015) Features: Keep it Simple As the tortoise, player can:
- Move left by holding the LEFT KEY
- Move right by holding the RIGHT KEY
- Jump up by pressing the SPACE BAR
Things that we don’t see in Version 1
- Physics: gravity, collision counter-force…
- Enemies, obstacles
- Props: trees, clouds, mountains
- Non-uniform terrains: cleavage, streams…
- Sounds
- Tutorial
- Game Pause
- Multiplayers
- Internationalization
Game Design
User Interface (HTML/CSS)
Rendering techniques
- CSS Sprite, CSS Backgrounds
- Fixed size HTML elements
Sprite appearance
- Animation with passive element repositioning
- Animations with CSS background positioning
Game Engine (JavaScript)
- setInterval to control the frame rate at 15 FPS
- requestAnimationFrame to schedule next repaints
- Use native event handler to handle simultaneous key inputs
- A simple gameLoop function to orchestrate game activities
- Apply OOP to manage game object states
- Control game object states based on FPS
References
- Game Programming Patterns by Robert Nystrom [http://gameprogrammingpatterns.com]
- Sprite source [http://www.spriters-resource.com/fullview/22504/]
- CSS3 Patterns Gallery [http://lea.verou.me/css3patterns/]
- Sky Gradients [http://codepen.io/zessx/full/rDEAl/]”