I made a tut. Its not so much learning for others as practice for me. please give any feedback on my tut making skills
index-
Chapter 1- simplest starts
1.framerate & sync
2. backdrops, sky spheres and hide mouse
Chapter 2- objects
1. how to design your game
2. media for your game
3. invisible objects and their use
Chapter 3- making your game
1. cameras
a. camera range
b. camera movement
2. making your game
a.making your charector
b. variables and inserting them into your game
c. using rnd to randomly place enemies
d. simple enemy ai
e. jumping and gravity
2. making your limb
a. medival sword
b. modern gun
c. fire rate
d. placing an object in the limb
Chapter 4- the finished product
the exe
distributing
CHAPTER 1
1.
sync on
sync rate 100
backdrop off
hide mouse
This is probably the code you start alot of the games with. however there are several things that could be changed to make it easier on yourself. The sync rate command refreshes your screen by __ times per second. Now, alot of computers lag when the sync is 100. your sync rate should never be higher than 60. The human eye blurs the images together after 27 fps, the human eye cant see a frame after 200 fps. The more fps the smoother the gameplay is. If your framerate was low, the game would be kind of jumpy, too fast and it runs slow (lag)
2.
The hide mouse command can be replaced by something even better and with less lag
do
position mouse 0, 0
this increases the frame rate and causes less lag, preventing freezing. Now, the
TEXTURE BACKDROP command does not work anymore, so you need a sky sphere or box. what this does is place a large sphere around the player and you texture it with the sky.
make object sphere, 1, 3000
load image "birdy sky", 2
texture object 1, 2
spheres and boxes have their uses. If your using a large map, that may be a problem because the larger the level, the larger the skybox/sphere (there are ways to solve this without making one large one)
CHAPTER 2
1.
to design your game you have to have a practical idea. if you want to make a great, online multiplayer game with perfect ai or the latest game of the year then thats good. The problem is you'll need to write thousands of programs to lear basic good enough to do that. Later you might want c++. Basically if your looking to learn then here are the bendable rules
1. try not to plan on making a great game (next halo great game)unless your planning on spending countless hours of work on it.
2. Don’t overdo the graphics until youre finished with the game. If youre not then you only need cubes and circles.
3. dont do a project that will take you twelve years because you probably will realize you need a different language to do what you want, then (maybe) after you learn that language and are ready to be creating your game, another language could come out.
Now i'm not saying you have to follow those. Thats why they are the bendable rules. basically i have this much- im making a game where black boxes (archers) shoot balls(arrows) and you kill them with your brown stick/limb/sword. Also there are brown boxes (enemy infantry) trying to attack you by running into you.
2.
Now with media. This section, as i'm not too familiar with objects, will just be a list of commands which you can look up in the dbpro index.
play object
play music
stop music
texture object
3.
Now, invisible objects are useful. when an object is invisible, it reduces lag. Lets say you place an object at your camera and keep it where your camera is. You would never be able to see the object so you dont need to see the object. You need the invisible object to use collision techniques. I've needed spinning cubes in several games. I’m using simple ai techniques by pointing the object and moving it. If i moved the rotating cube, it would go around in circles. So you need to place an invisible ball, place a cube where the ball is, rotate the cube and move the ball towards my player. hide the ball to reduce lag.
Chapter 3-making the game
1. Cameras
The basic camera is zero, you only need to create another camera if youre using 2 players. The basic camera commands are
control camera using arrowkeys
turn camera right/left
camera position x/y/z
move camera
make camera
set camera view
set camera to follow
screen width(not the width of the camera, the actual screen)
screen height
Set camera view, screen width and height can be used for 2 cameras by using
set camera view cam#, screen width(),screen height()/2, screen width,0
syntax-set camera view (camera), left, top, right, bottom
To do the second camera trade positions of the 0 and screen height()/2
a. Camera range is simple, and is most commonly used in dungeons, foggy games etc. it
simply limits the sight of the camera
set camera view camera, near, far
This can be used if you want to have surprise attacks or something similar.
b.Camera movement may not be as simple as camera range but its still pretty simple.
Control camera using arrowkeys camera, movespeed, turnspeed
This is what is usually used for first person games where the character is placed inside the camera. You can also use turn camera left/right and move camera commands but you really should only use those if your making a custom movement. you should/could also use the
SET CAMERA TO FOLLOW Camera Number, X, Y, Z, Angle, Distance, Height, Smooth, Collision
the xyz coordinates are usually with the object position x/y/z commands but you can do other things with them. The others (angle, distance, height, smooth and collision) are pretty much self-explaining.
2. Making your game
a. making your character.
The main thing about a character is the size. In one game a 20 sized object could be huge and in another it could be really small. In one game a person used a size 1 object and then used the set camera to follow command to zoom in on the object.
b. variables and inserting them into your game.
Variables have many uses, they can be used as gravity, object numbers, camera numbers, enemy states, from a to z they can be used with lots of things. common commands
for to
type/ endtype
dim
operators-+or plus;-or minus;*or multiply;\or divide
inc/dec
these are the most common commands and they have many uses, theyre very program specific.
c. using rnd to randomly place enemies
Rnd is random, its very easy to place enemies with it
syntax-rnd(range value)
to use it to place enemies simply do
position object ene, rnd(10000),0,rnd(10000)
Rnd can be used for anything but what it does is create a random variable. it is commonly used as
(name)=rnd(100)
`only to limit the rnd
if (name)>/</=(number) then (name)>/</=(number)
d. simple enemy ai
AI doesn’t really become ai until it judges all the options and then acts upon that. So there really isn’t simple ai. The simplest ai just points the object at the player. This can be don’t by…
do
point object ene, player position x(p1) , player position y(p1), , player position z(p1)
move object ene, 1
loop
this is the simplest enemies can get.
here is ai basics
If the object is close to the object by a certain distance, it changes from mode 1(wandering) to mode 2(attacking). For more advanced ai there can be sub-states. lets say your in attacking state, strafing&firing or attacking duck, ducking and firing. there are also sub-sub states and sub-sub-sub states but you wont be using those.
first make an array using the dim command. You only need to make an array if your using multiple enemies, so lets just use 2
dim enemies(2)
Next create the enemies, this can be done using the for/next command
for t=1 to 2
make object sphere 1+t, rnd(50)
color object 1+t,RGB(rnd(255),rnd(255), rnd(255))
next t
T can be anything you want. Now make a cube, just for an example of ai distance
make object cube 1, 50
Then, in the do, the ai
do
for t=1 to 2
distance=SQRT(object position x(t)-object position x(3))^2+(object position y(t)-object position y(3))^2+(object position z(t)-object position z(3))
if distance<100
enemies(t)=1
endif
if distance>100
enemies(t)=2
endif
if enemies(t)=1
move object 1+t, 1
turn object right 1+t , rnd(10)
turn object left 1+t, rnd(10)
endif
if enemies(t)=2
move object 1+t,5
endif
e. Simple Gravity
Most people use a variable named YSpeed#. Which is, obviously, the speed upwards. When negative, it goes down, when positive, it goes up.
Now, the gravity is a vector that pulls our object down, when the object goes up, it slows down and edventually will accelerate downwards. This means our calculations would be something like this: dec YSpeed#, gravity#.
(Usually gravity is a constant)
If the object hits the ground, a new force works on the object, normal force, which is always -ForceDownwards (-Fz). In other words, the yspeed gets increased by itself, which gives 0.
To effect the gravity on the player, you have to increase the players position y with the YSpeed#.
posy# = object position y(id)
`effect gravity
dec YSpeed#, Gravity#
`Check for collision with ground
if posy# <= get ground height(id, X, Z) + (object size y(id)/2)
YSpeed# = 0.0
endif
`effect position
inc posy#, YSpeed#
`update
position object id, X, posy#, Z
[edit] sorry about italics
[img]http://www.savefile.com/files/4182721 [/img]