i think i want to make my own small guide about darkbasic this will be about controling a object its now huge but inportant in almost all games
okay first we want to make a object we can do so with this command:
the first number is the nuber of the object the next number is the scale of the object.make object cube 1,100
now we want it to check if some of the keys we use to control it is pressed. And we want it to do it forever so we put
after the make object command and put thedo
command at the buttom it will make it do all betwen do and loop until we breaks the loop but in this program we dont wanna do soloop
now we want it to rotate its yangle if we press left arrowkey we do so with this command
the "if leftkey()=1 then" part of the command make the program only do the following command if the leftkey is pressec because =1 means pressed 1 will always mean on and 0 will always mean unpressed and "if" mean if the following condition is on the program will do the following commandif leftkey()=1 then yROTATE OBJECT 1, OBJECT ANGLE y(1)+1
thepart of the program will make the program rotate the objects yangleyROTATE OBJECT 1, OBJECT ANGLE y(1)+1
the "yrotate object 1", make it rotate the yangle a nuber of degress must be betwen 0 and 360 but we want it to change its yangle by 1 evry second not just set it to exampel 10 so indstet of have a command that look like this
"yrotate object 1,10"
we make another command
"object angle y(1)+1"
it takes the yangel of and object the number of the object is in () after the command in this case its 1. (but you should know that) and + it with 1 so we move 1 more degress than we already is on
and i dont know where it will be good to post this but the number1 in the yrotate object 1
is the number of the object we want to rotate
now we want to do the same but with another key and another angel we want to change you should know what to do here we want to make one where we change the z angle when press right and x angle when press up
you should know how to do that but if not read it bether
now we want it to move when press space we do so with the following command
the first part "if spacekey()=1 then" you should now what that doif spacekey()=1 then move object 1,10
the "move object 1,10 "
move the object the first number is the number of the object we want to move and the next number is the speed
CONGRATULAISION YOU HAVE MADE AN CUBE UNDER YOUR CONTROL
here is the complete program
PLEASE LEAVE A COMMENT ITS MY FIRST GUIDEmake object cube 1,100
do
if leftkey()=1 then yROTATE OBJECT 1, OBJECT ANGLE y(1)+1
if rightkey()=1 then zROTATE OBJECT 1, OBJECT ANGLE z(1)+1
if upkey()=1 then xrotate object 1, object angle x(1)+1
if spacekey()=1 then move object 1,10
loop
OHH AND WARSHEEP I DIDNT KNOW HOW TO MAKE [/CODE] SO I MADE [/QUETE]
Donate to remove ads.