Random Jumping

Game Editor comments and discussion.

Random Jumping

Postby catacomber » Tue Apr 29, 2008 2:35 am

How would you, on left mouse button down, make an object you click on with the mouse jump in any of 8 random directions? And jump at least 4 pixels? When it jumps outside the view, it's destroyed?

Would it be like this?

jump=rand(8);

Then use timer ...
Code: Select all
if(jump==0)
{
//jump 1
}
if(jump==1)
{
//jump 2
}
and so on...

?

for the randomness part?

Is there anyway to change the background to a solid color without using a background graphical actor?

I've tried searching both these topics but can't find anything exaclty what am looking for.
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Random Jumping

Postby pyrometal » Tue Apr 29, 2008 3:10 am

You got it right, your code would work, but it would far more efficient if you used switch/case statements instead:

Code: Select all
char jump = rand(8); //Ranges from 0 to 7.

switch(jump + 1)
{
    case 1: //Jump 1 code here.
            break;

    case 2: //Jump 2 code here.
            break;

...

    case 8: //Jump 8 code here.
            break;
}


GE doesn't allow the background color to be changed on the fly unfortunately, so you would have too use a completely white graphical actor and change its RGB values to obtain the wanted color. That's how I do it!
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Random Jumping

Postby catacomber » Tue Apr 29, 2008 3:23 am

Thanks, pyrometal, I'll try it.

How do you change the rgb colors of the white background?
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Random Jumping

Postby pyrometal » Tue Apr 29, 2008 3:33 am

Just specify it in the actor's code with "r = value;", "g = value;", and "b = value;". I you want to change that with another actor, just specify it this way, "actor_name.r = value;". ("value" is a number or a variable.)
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Random Jumping

Postby catacomber » Tue Apr 29, 2008 3:38 am

Where in the actor's code. Actor is white backdrop right? I know this is like eating oatmeal for breakfast for you but GE is new to me and am trying to find my way around. :D I know what you mean by value but don't know exactly where in GE to plug that in. : )

Are you talking about Create Actor or Draw Actor Script Editor? and then you input that code?
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Random Jumping

Postby pyrometal » Tue Apr 29, 2008 4:05 am

Code: Select all
switch(rand(8)+ 1)
{
    case 1: //Jump 1 code here.
            break;

    case 2: //Jump 2 code here.
            break;

...

    case 8: //Jump 8 code here.
            break;
}


Even better! (as described in PM)
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Random Jumping

Postby catacomber » Tue Apr 29, 2008 1:39 pm

If would like the balls to bounce a few pixels in the opposite direction when they collide with a wall, whether the wall is on top, bottom, left or right, how would you do it? I found a diagonal walking demo but not a bouncing one--I guess bouncing would be not too far off. : ) Still looking for diagonal bouncing demo but then it has to bounce in a direction opposite to its collision direction--has to be repelled in the opposite direction on collision with any top, bottom or side wall by a few pixels.

And how would you write the random variable jump for a diagonal? Will try to search the last one---couldn't find anything here on the first.
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Random Jumping

Postby pyrometal » Tue Apr 29, 2008 7:12 pm

Could you tell me what this is for in order for me to understand better the problem and what you to accomplish? It's hard to help without knowing what how and why it'll be used. I'll be waiting for an answer! ttyl
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Random Jumping

Postby catacomber » Tue Apr 29, 2008 9:04 pm

It's for a very simple game of one screen with gray balls and red balls. If you click on the red balls with your mouse, you spawn two new balls that bounce away from you. If you click on the gray balls, you can destroy them. If you can click on and destroy all the gray balls, the red balls will disappear also and you win. The idea is to avoid the red balls and hit the grey balls. But the red balls should be bouncing around madly at the same time you're trying to take out the gray ones so it's not that easy. I don't know if I can do it but would like to try.

One problem is what happens if a spawning ball tries to occupy a spot already occupied by an already in game ball--does the game crash? Another problem is that the spawning balls and the gray balls would have to be able to move in the randomly generated paths we mentioned above with a bouncing effect and bounce in the opposite direction when they hit the walls of the screen. I guess that might be done with a wire region.

It's a silly game but if i can do it it will teach me a lot about scripting game editor.
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Random Jumping

Postby pyrometal » Tue Apr 29, 2008 9:10 pm

ok, I get it. I'll post a demo showing a few of the things you need sometime tonight. As for creating an actor into another actor, the collision will be ignored, and the game will not crash.
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Random Jumping

Postby catacomber » Tue Apr 29, 2008 9:13 pm

Thanks, pyrometal. :D It takes very few graphics--just a tile for the boundary wall and two balls--could be black and white but would be interesting from a scripting perspective. : )

There has to be a way to test whether the smacked gray balls are all "dead", so that all the red balls disappear off the field. : )

If clause. : )
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Random Jumping

Postby pyrometal » Wed Apr 30, 2008 1:27 am

Here's a good method of doing your collisions WITHOUT using the PhysicalResponse(); action. This method conserves the velocity of the balls exactly, no loss like PhysicalResponse, and is also must easier to process. A lot of comments are included in the code to explain it. Good luck!
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Random Jumping

Postby pyrometal » Wed Apr 30, 2008 1:29 am

Bouncing Balls demo.zip
Oops!
(197.25 KiB) Downloaded 112 times
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Random Jumping

Postby catacomber » Wed Apr 30, 2008 2:51 am

This is great!!!!!
I see the comments and they're very helpful. The code is actually very lite.

Why don't you post this in demos with the data file -- can't be too much. : )

So other newbies can see it. :D

I'm pro newbie.

Were you able actually to click on the blue ball? I couldn't but will keep trying.

Your sense of humor and delight in challenges is very evident in this game. : )

Nice game wall. : )

Thanks, pyrometal.
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Random Jumping

Postby pyrometal » Wed Apr 30, 2008 3:07 am

Thanks, no problem, and anytime! :D I think people can find it here if they need it, no use to post the same thing twice! ttyl
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron