Collisions with Same Code Do Different Things

Talk about making games.

Collisions with Same Code Do Different Things

Postby plinydogg » Mon Dec 12, 2005 2:54 pm

Hi everyone! I'm having a lot of fun learning how to use GE! I have a question I was hoping someone would be able to answer.

When the main actor collides with a bomb, I needed to start the level over and change some variables (e.g., move the main actor back to starting position, reduce the number of lives by one, clear all enemies from the field of play, etc.).

To accomplish this, when the actor collides with a bomb, the main actor is moved to an offscreen area (a wire-framed region) where all the variables are changed appropriately, the main actor is moved back into starting position, the current level is displayed, etc. This offscreen area is above the main field of play but is in the same activation region.

This works perfectly if the main actor collides with a bomb that is located in the top half of the screen (closest to the offscreen area), but it doesn't work if the main actor hits a bomb in the lower right portion of the screen. The code is identical for both bombs, and I cannot figure out why it works for collisions with some bombs and not others.

I have tried everything I can think of, including:

--making another off-screen region below the main field of play and sending the main actor to it if the main actor collides with a bomb on the lower half of the screen;
--tweaking some timers to make sure that the actor has enough time to reach the offscreen area (which is farther away from bombs on the bottom half of the screen than it is for bombs on the top half);
--Moving the offscreen area to different positions around the main field of play.

I can't think of what to do next! If anyone has any general ideas about what can cause identical code to sometimes produce different results, I would greatly appreciate it! And if anyone has any more specific ideas on how to fix this problem, I would also greatly appreciate it.

Thanks for the help in advance!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby Kodo » Mon Dec 12, 2005 3:36 pm

How are you moving the actor? A simple way to move objects to specific places is to put a filled region where you want to move things to and then move the object to its x and y position.

something like...


char.x = restart_position.x;
char.y = restart_position.y;


Where char is the name of your player actor and restart_position is the name of the filled region you want to move your objects to. then if you decide to move them somewhere different you only need to move that region and don’t need to worry about finding the actual grid coordinates. This is also a very easy way to move the 'view' around when jumping to new levels or menus :)

Hopefully that helps? Or have I not understood your problem?
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby plinydogg » Mon Dec 12, 2005 4:21 pm

Thanks for the reply!

I use a similar method to the one you suggested, with a few minor modifications:

I think because I have too much going on with the Main Actor, nothing happens if I tell it to do something when it collides with a bomb. Instead, I have to assign those instructions to the bomb's collide with Main Actor event. The bomb's collide with main actor event then sends the main actor to a wire-framed region (I also tried it with a filled region, but the same result happened), which resets all the variables, places the main actor in the proper spot, etc. Like I said earlier, this method works fine for a majority of bomb collisions but not with the ones in the lower (especially the lower righthand) part of the screen.

Just to be clear: the movement part works fine: i.e., the main actor always ends up in the the appropriate spot after a collision with any bomb. But other code isn't executed: for example, I have a timer that starts once the main actor is moved to its starting position and during which the current level is displayed and the player cannot move the main actor. Once this timer expires, the level message hides itself and the player can move the main actor again. It is only this portion of the code that sometimes fails to execute (i.e., the part hiding the level text and re-enabling the main actor events).

It's just weird!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby plinydogg » Tue Dec 13, 2005 3:29 am

Okay. I've tried everything I can think of and nothing fixes it...I can come up with no workaround! I just don't understand: there is nothing different between one bomb and another other than their clone numbers and their position on the screen!

Neither of these can be the problem right?

It can't be the clone numbers of the bombs because I'm not doing anything to the bombs (i.e., I dont' destroy the bombs).

The only way I can think that the different bomb positions would matter is if using the moveto command forces an actor to collide with things between where it was and where it is moved to. But this isn't the case, is it?

Any ideas (even if crazy) are still greatly appreciated!!!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby Kodo » Tue Dec 13, 2005 10:37 am

Very odd. I don't suppose you could post a Ged & data files with an example of your problem?
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby plinydogg » Tue Dec 13, 2005 1:00 pm

I sure could (and would really appreciate someone taking a look at them), but I don't have a webpage on which to host them. Alternatively, I could e-mail them to anyone who is interested....

Thanks!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Tue Dec 13, 2005 1:08 pm

You can send to my email with "Collisions with Same Code Do Different Things" in the subject
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby makslane » Tue Dec 13, 2005 5:21 pm

You are creating the mines in a timer event based on minesInPlay count.
To make sure the count is accurate, make this changes:

Mine -> Create Actor: minesInPlay++;
Mine -> Destroy Actor: minesInPlay--;

When you need count actors, it's a good idea give the control to actor using Create and Destroy Actor events.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby plinydogg » Tue Dec 13, 2005 8:45 pm

Thanks for the help! I really appreciate it!

I think that took care of the problem (but I'm not entirely sure yet). I'm going to go back and try to tighten up the code a bit.

Thanks again!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby plinydogg » Sat Dec 17, 2005 4:02 am

Argh!!! Unfortunately, this did not cure the problem :( For whatever reason, when the Main Actor hits bombs in the lower right-hand portion of the screen, the appropriate collision->script editor code fails to execute.

I will keep trying to find a workaround, but if you get bored and feel like taking another look I'd be mighty greatful.

Thanks,

Plinydogg
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Sun Dec 18, 2005 1:58 pm

Send me the new game version
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby makslane » Mon Dec 19, 2005 3:38 pm

You are moving the outside the current region.
So, the created actors (and your timers) in this region will be destroyed, if outside of the view.

You are using timers to create the actors again, but the timers will be destroyed with your actors.

You can try put the timers used to recreate the level in the view actor.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest