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 Professional Discussion / Valid Code or not?

Author
Message
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 18th Mar 2010 01:17
Self explainable:



IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Mar 2010 01:35
Yes.

... providing sprites 11, 12 and 'spritenum' exist at the point the code executes, and that the function 'Bounce' exists.

Why? What made you ask?

Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 18th Mar 2010 01:57 Edited at: 18th Mar 2010 01:58
In my program, there are 4 sprites that act as borders such that when any normal sprite (w/in the borders) hits them, it bounces off. However, I have noticed some sprites (w/in border) disappearing, and when the number of sprites increases, more and more disappear. I was wondering if that code was faulty.

Dragon Knight
19
Years of Service
User Offline
Joined: 10th Jan 2007
Location: Newcastle
Posted: 18th Mar 2010 03:33
To do a simple check weather it's doing that function or not, you can simply put:



Perhaps your bounce function is actually sending your other sprites flying off in a direction or something, it's a bit hard to help without more code, sorry

Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 18th Mar 2010 03:56
here is the bounce function:



Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 18th Mar 2010 07:45
in your first post, it is only true if your target sprite collides with sprite 11 and 12 at the same time it is checked.
Bounce() won't get fired if collision only occurs with 11 and not 12, or 12 and not 11.
Dragon Knight
19
Years of Service
User Offline
Joined: 10th Jan 2007
Location: Newcastle
Posted: 18th Mar 2010 16:57
ahm why minus 165 for angle? why not 180? As if your object is moving near the angle of the wall it will shoot across the screen xD depending on how big the sprite is

Tip, instead of all this confusion have a few variables for location, rotation, and speed.

Location having x and y
rotation having Angle
Speed having x and y

Then you can easily print of each, and tell weather it's going 9999 miles per hour, or it's position is just out of the screen or it continuously flies off..

What might be happening is that your moving your object -40 it may still be in another collision and bang it's another -40 and so on, it's hard to tell considering i cannot see the project in action

Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 21st Mar 2010 06:25
i could send the program but i am doing science fair now, so...maybe in a couple of days

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2010 20:44
You seem to be using four sprites for borders but only check two. Is that intentional?
Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 21st Mar 2010 22:54
i am using all four:



and here are border positions:


borders are longer then screen width and length and "hori" means horizontal

Jedi Padawan
17
Years of Service
User Offline
Joined: 17th Jun 2009
Location: None of your business
Posted: 21st Mar 2010 22:55 Edited at: 21st Mar 2010 23:00
thanks

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Mar 2010 01:03 Edited at: 23rd Mar 2010 01:49
Have you checked carefully that each "bounce" actually gives you a direction inside the area? It isn't obvious to me that "-165" always works - although it might.

Incidentally, does your code bounce three times when two of the collisions are true - and, if so, is that intentional?

Edit I think it would help if you posted code that fails - not much point posting the working parts of your code. The following simple demo works fine for me (OK, to be honest, I got bored waiting for it to fail):

Login to post a reply

Server time is: 2026-07-26 23:40:25
Your offset time is: 2026-07-26 23:40:25