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 / How to make an if statment that applies to any sprite

Author
Message
arbiter chewbacca hybrid
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 27th Jun 2009 23:36
If you are making a game with a physics engine so that when somthing jumps or is dropped that it must come down such as...

this isn't real code

If any object jumps
then make it come down.


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
Brick Break
User Banned
Posted: 27th Jun 2009 23:40
Awesome, I didn't know that! Sticky it!
/sarcasm

That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 27th Jun 2009 23:41
............in a word, DDDDUUUHHHHHHHHH

There are only 10 kinds of people in the world, those who understand binary and those who dont
Brick Break
User Banned
Posted: 27th Jun 2009 23:44
Permanoobs are awesome.

That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 27th Jun 2009 23:48
ROFLMAO!!!

hahaha

There are only 10 kinds of people in the world, those who understand binary and those who dont
Brick Break
User Banned
Posted: 27th Jun 2009 23:49 Edited at: 27th Jun 2009 23:51
I think I'll quote myself there in my sig...

EDIT: Sig'd!

Permanoobs are awesome.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 27th Jun 2009 23:53
Technically, it doesn't go DOWN. It heads towards the center of mass of the greater body. Normally, for us that IS down, but it could also be up if we are falling upside down

Anyway, was there a question there? I didn't even see anything about a sprite in that...

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Jun 2009 23:58
What?


Make the path of your enemies easier with Waypoint Pro!
arbiter chewbacca hybrid
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 28th Jun 2009 00:00 Edited at: 28th Jun 2009 00:03
No I'm asking how to make an if statment that applies to all objects.

Edit:
I mean for sprite or object how to make an if statment that applies to any sprite or object depending on the situation. So you don't have to redo the code for every object.


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 28th Jun 2009 00:08 Edited at: 28th Jun 2009 00:10
Just use a for loop. To make it efficient, you will need to structure your media, ie

Sprites 1-400 are static and don't need physics applied.

401-1400 are enemies

1401-1800 Are objects that need physics

etc...

That way you can run a for check on specific groups, like


@Thecomet
I was referencing relativity of points of reference. Here is an example:

If you wake up in a train that is on a perfect smooth, straight track with no doors, cracks in the wall, or windows, how will you know if you are moving?

The answer, you won't until the train turns or something like that.

Similarly, UP is a reference to what is above something from a specific frame of reference. If I look at someone falling upside down, to me they are falling down. However, to them they are falling towards their head, which is up to them. If THEY were to wake up falling upside down is a dark cave (so they can't see anything else), how would they know if they are falling or flying? Again they can't.

Also, gravity pulls everything to the center of MASS. Again, though, it is a frame of reference thing. If you are using the Earth as the frame of reference, heading towards the top of the planet is up and the bottom is down, rather than towards the center for down and the atmosphere for up.

Summing up: I was just being a smart a$$ with frames of reference.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
arbiter chewbacca hybrid
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 28th Jun 2009 00:16
SO would I just declare the variable such as this sprites#1,2,3,4,5,6,7,8,9 = "bad guys"
If "bad guys" = 0
then make em come down to the ground

(not real code)


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 28th Jun 2009 00:21
Pretty much. Just structure your sprites so that they are logically grouped for both physics and ease of use.

Then just us a for loop and if they aren't touching the ground, bring em down.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Jun 2009 00:40 Edited at: 28th Jun 2009 00:42
Variables are the answer to this - using arrays in particular.

Say your jumping objects are numbered 100 to 150 you could use one array to store the state of the object and another to monitor it's position.

Here's some highly simplified pseudo-code which should point you in the right direction:



As you can see, using arrays for an object's X, Y and State values, you can access them in a For..Next loop.

If arrays are a mystery to you, you'll find them covered here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Barrie

Login to post a reply

Server time is: 2024-05-20 13:19:03
Your offset time is: 2024-05-20 13:19:03