AppGameKit Classic

AppGameKit Classic

评价数不足
AppGameKit - Primer
由 Gasius 制作
AppGameKit - Primer

The basics and some more advanced ideas and game design mechanics....
   
奖励
收藏
已收藏
取消收藏
Getting Started - The main game loop
In the beginning....

Starting a new game can be daugnting to say the least, especially if you have no idea what your game is going to be about or where you want to go with that little idea running around in your head.

The idea behind this tutotial, is to help you get started and maybe find your way to some great new ideas.

I find playing with the AppGameKit commands, changing parameters, just getting a feel for a specific commands' capabilities can turn on a little light in the darkest recesses of your mind, giving you direction for a whole new game idea or gaming concept. Often you will realise and say to yourself, "Hey, I have seen that techique in other games...", thats because there are patterns to the way certain things work the mechanics can sometimes be so simple, you will kick yourself.

Before you know it you will be building a little game, and slowly you will start adding to it, and before you know it, you will have a fully fledged game.

Don't get ahead of yourself by trying to develop that next big block buster on your first day. Get to know the tool, get a handle on the commands first. You will write the same code over and over many times before you find that perfect effect or that something special that makes your game different.

Take baby steps at first. You will find your journey much more gratifying if you take small steps that add value each time you run you game. Follow an agile approach "Small deliverables, more often"

Before you wite your first line of code, design yourself a logo for your games. We will use thee logo in our second lesson.

So, lets start by taking a look at the main game loop....
Create a new project - Hint : call it whatever you like if you don't already have a name (Coming up with a name for your game is not as important as building your game, a really cool name will come to you later)

The basic code tempate for a new game looks like the following...

// Project: Lesson One // Created: 2018-02-20 // show all errors SetErrorMode(2) // set window properties SetWindowTitle( "Lesson One" ) SetWindowSize( 1024, 768, 0 ) SetWindowAllowResize( 1 ) // allow the user to resize the window // set display properties SetVirtualResolution( 1024, 768 ) // doesn't have to match the window SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts do Print( ScreenFPS() ) Sync() loop

When you run the application; the framerate as close to 30 frames per second is diplayed in the top left corner.
You will notice, the main loop is a never ending loop, that just runs forever. Don't panic, we will build in a means by which the gamer can end the game. For now simply close the window, yes I know, you ran it didn't you? Ok, go ahead and close it.

In the main loop you have two commands. A Print command and a Sync command between the do .... loop commands (dont worry about the other commands at the top, we will cover them in later lessons. The defaults will be fine.

The Print command, is most likely going to be one of you first goto commands during the hole phase of you development. You cn use it to print high scores, story lines and even use it for debugging your game. (Note : The latest version of AGK has a realtime debugger built in).
Fundamentally using the debugger is great, but sometimes you just want to display the value of variables while your game is running (the old way of debugging).

It is important to note, if you want to make a comment in your code, simply use the C# syntax //anything after the slashes will not execute

The Sync command at this point, is the most important lin of code. Without it, nothing will be rendered to the screen. (Note : So dont forget to Sync)

引用自 Andrew van Dijk (GasiusGames)
Never Underestimate Radical Vision