Back to Top



WELCOME!

My name is Jason Hensley. I teach students how to build great games for a living.

This website shows a few of my courses. Contact me to get access to the entire library, or hire my one-on-one gamedev services for your next game project. I am proficient with all the top game engines: Unreal, Unity, Gamestudio, etc.

COURSE SAMPLES

An Introduction to Game Development

Course outline:

- Lesson 1: The main game loop. Managing player's input

- Lesson 2: A solid player movement framework

- Lesson 3: Working with bitmaps and 3D models

- Lesson 4: Using a level editor

- Lesson 5: Sound and music for games

- Lesson 6: Materials and shaders

- Lesson 7: Rigid body physics

- Lesson 8: Frame rate optimization

- Lesson 9: Best game engines for newbies

- Lesson 10: Additional resources

Lesson1: The main game loop. Managing player's input


Welcome! This course will teach you how to approach game development the right way. Let's begin by discussing the three core components of any game:

1. The main game loop, which is responsible for updating all the necessary game elements.

2. Code that processes player's input. This is the code that tells the game engine to fire a projectile when you click the left mouse button, for example.

3. Rendering code, which displays the potentially visible objects on the screen.


Here's the lite-C source code for a very simple game, which moves a panel across the screen, and incorporates all these elements:


#include

PANEL* ball = {

bmap = "ball.pcx";

layer = 11;

pos_x = 504;

pos_y = 344;

flags = SHOW;

}

function main()

{

fps_max = 60;

wait (1);

video_window(vector(100,50,0), vector(800,600,0), 1, NULL);

while (1)

{

  if (key_w)

       ball.pos_y -= 1;

  if (key_s)

       ball.pos_y += 1;

  if (key_a)

       ball.pos_x -= 1;

  if (key_d)

       ball.pos_x += 1;                  

  wait (1);

}

}


The first line of code includes the needed graphics library, which takes care of the rendering process as well. Most game development platforms already include highly optimized graphics routines, so you won't have to reinvent the wheel. It's the perfect solution, because it allows you to focus your energy on building the code for the actual game.

The next few lines define a panel, the little grey square in the image below.

Function main is the one that's run anytime the game executable file is opened. It's also the ideal place to put the instructions for your main game loop.

We have used a while (1) loop in this example. The "while (1)" instruction is equivalent with "while 1 is equal to 1", so it will run forever. In this case, that loop will be constantly checking for player's input.

If one of the "W", "S", "A" or "D" keys are pressed, the grey panel will be moved by a pixel each game frame. And since we have set the frame rate to 60 frames per second, it means that our small panel will be able to move with up to 60 pixels per second, get it?

This concludes our first game development lesson. I am sure that you've got some questions now, but don't worry, we will answer them all in the following lesson.