Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Object Position.

Author
Message
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 10th Jul 2006 21:35
Hello. I've been thinking about something. Could you be able to cause something to happen when the object position equals a certain position?

Here's what I've managed to put together as an experiment.



"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
flock
19
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 10th Jul 2006 22:03
Of course!



This does basically the same thing but with a few IF statements implemented to produce actions about the position of the object. Rather, actually it defines actions within the parameters of the variable of the object's position.

a.k.a. "flockhound"
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 10th Jul 2006 22:54
Would that apply to 3D also? or would you do it a little different?

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
flock
19
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 11th Jul 2006 18:04
What do you mean? Did you compile and run the code? This is 3D. If you meant 2D then "yes."

a.k.a. "flockhound"
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 12th Jul 2006 06:52
Oh sorry. i guess it looked at it wrong. Anyways, thanks i'll try to change it as i need it.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
flock
19
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 12th Jul 2006 11:21
Hey, man, ask away

a.k.a. "flockhound"
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 13th Jul 2006 13:42
Don't know if i should post this as a new thread so i'll ask anyways. I've been trying to do like half life (or most games) to be able to press a letter, have something happen then when that letter is pressed turn off the thing that happened. you know what i mean?

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 13th Jul 2006 14:00
if you mean toggling:


the hold variable is used to prevent toggling with superspeed.
TheThingThatHasToBeHandled, well, I think you know what that does.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 13th Jul 2006 20:36
You can detect anything out of any IF statement and IF case. Got that?

If check#=1

If object size x(1)=24

if object exist(1)

if camera position z()=95

Can't beleive its not butter.
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 13th Jul 2006 23:40
Sven B, you kinda confused the hell out of me. could you give me an example that actually does something? cause i'm lost....big surprise there :-P

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 14th Jul 2006 16:54
Sure:



keystate(key) detects if the key is pressed. key is a number that represents a key from your keyboard. (you can search the forums for a map of the numbers).

and hold = 0 is used to prevent that the toggle goes very fast. If you press the key, and it all repeats (when looping) then that key would be still pressed (almost nobody can press a key for 1 loop), and the variable will be swapped again almost directly.
hold = 1 is used for this above.
If you add this, you will press a key, and hold = 1. But the next loop, hold = 1, andthus the program will not swap the variable again.


There's nothing much to say about this. If the variable = 0, then make it 1, else (if the variable = 1) then reset it to 0.


Ofcourse, if we put a "lock" (hold) on the key, we have to be able to unlock it.
scancode() returns the key number of any key pressed. (Kinda like the opposite of keystate(key)), so if no key is pressed, unlock the key for another toggle.


This if statements checks if the variable is toggled on (1), and if so, then it has to do something. HandleThing() is not a command or anything, it's just to show that that's the part that you have to code the action.

An example:


And this is what happens when you leave out the "hold" part:


I hope it's a bit clearer now.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 14th Jul 2006 17:02
Lover I realllllly recommend you read some tutorials, IF statements are pretty much the first thing you should've learnt with programming, next to variables.

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 14th Jul 2006 17:05
If commands and Variables (especially) are the easisest things to learn!!!

flock
19
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 14th Jul 2006 18:03
Right. You go, Jason, you're the best!*



* sarcasm

a.k.a. "flockhound"
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 21st Jul 2006 08:39
Thanks, sorry it took me so long to answer I've been trying to learn other stuff besides DB. Sven B, it's a bit clearer not, i'm going to expirement and try different commands.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack

Login to post a reply

Server time is: 2025-05-25 08:43:34
Your offset time is: 2025-05-25 08:43:34