Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 2
Reputation: 3
Posts: 36
Join Date: Sep 2007
[guide] how to make a spining cube under your control -
03-23-2008
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:
Quote:
make object cube 1,100
the first number is the nuber of the object the next number is the scale of the object.
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
Quote:
do
after the make object command and put the
Quote:
loop
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 so
now we want it to rotate its yangle if we press left arrowkey we do so with this command
Quote:
if leftkey()=1 then yROTATE OBJECT 1, OBJECT ANGLE y(1)+1
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 command
the
Quote:
yROTATE OBJECT 1, OBJECT ANGLE y(1)+1
part of the program will make the program rotate the objects yangle
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
Quote:
if spacekey()=1 then move object 1,10
the first part "if spacekey()=1 then" you should now what that do
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
Quote:
make 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
PLEASE LEAVE A COMMENT ITS MY FIRST GUIDE
OHH AND WARSHEEP I DIDNT KNOW HOW TO MAKE [/code] SO I MADE [/QUETE] [Only registered and activated users can see links. ] to remove ads.
Why didn't ya use the code tags? It gets allot easier to read then..!
Anyways, good for a first guide.... and... since I feel nice today..
But I actually expect to see some code tags around the code parts!
( [code] [/ code] without the space between / and code. The code goes between the tags)
<ToXiCa> warsheep + denmark + VIP lounge + cheese = love <3 FOR A MOMENT, NOTHING HAPPENED. THEN, AFTER A SECOND OR SO, NOTHING CONTINUED TO HAPPEN.
The programming sections aren't that much used, this thread has actually gotten a high amount of comments, imo atleast.
You should create some more guides, or work more on this one. Like, a button to break the loop and stuff, so people could learn how to use this in a more needed way, if you get me.
<ToXiCa> warsheep + denmark + VIP lounge + cheese = love <3 FOR A MOMENT, NOTHING HAPPENED. THEN, AFTER A SECOND OR SO, NOTHING CONTINUED TO HAPPEN.