how to do random stuff

Non-platform specific questions.

how to do random stuff

Postby raminkhan » Sat Nov 19, 2011 5:34 am

Here I attached a file which shows what I need. Okay I got a ball on a screen ALL IN X-DIRECTION. okay now this ball comes on screen, gets hit by the players gun then it stops for a minute then moves toward other objects on X-AXIS then destroys them. then it rolls off the screen. if you can't clearly understand what I mean then please see this .swf file animation. thanks a bunch friends.
Attachments
whatever.exe
(986.67 KiB) Downloaded 88 times
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: how to do random stuff

Postby foleyjo » Sun Nov 20, 2011 12:23 pm

Quick run down of what to look at to get this to work.

Do this in the balls events and make an actor variable called speed

in create actor use
Code: Select all
xvelocity = speed;  //speed being an actor variable that holds the speed

In the collision between the ball and the bullet
Code: Select all
xvelocity = 0;  //stops the balls movement
createtimer(); //create a new timer (Note you will have to fill the details in for this ti have the correct time and don't loop it)

when the timer ends you want to change the speed value to whatever you want the new speed to be then multiply it by -1 to reverse direction
Code: Select all
speed = speed * -1; //reverse the direction
xvelocity = speed;

On collision with any of the 2 objects do the same
Code: Select all
speed = speed *-1;
xvelocity = speed;

On out of vision destroy the actor
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Re: how to do random stuff

Postby raminkhan » Sun Nov 20, 2011 11:46 pm

can you please make a demo file for this I am really having trouble doing it because its just not working.
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: how to do random stuff

Postby foleyjo » Mon Nov 21, 2011 3:59 pm

Not got a lot of spare time at the moment but I quickly knocked up this little prog that demonstrates what I said to do.
You will need to change the actors to match what you want.
The ball will move in one direction till it hits one of the actors on either side. It will then change direction.
Pressing space will make the bullet shoot up. If the ball collides with it there will be a pause and then it will continue in the opposite direction.

Haven't done anything with the direction of the bullet, it will only move up the screen in this demo so try and time it right.
I have also kept the speed of the ball slow so it's easy to hit.

Let me know if there's anything you don't understand
Attachments
thing.ged
(1.97 KiB) Downloaded 94 times
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Re: how to do random stuff

Postby raminkhan » Mon Nov 21, 2011 6:07 pm

LOVE YOUUUUUUU MMMMYYYYYY FFFFFRRRRRIIIIIEEEENNNNDDDD, YOUR AWESOME. THANKS A BUNCH.
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: how to do random stuff

Postby foleyjo » Wed Nov 23, 2011 10:45 am

small update as requested in PM
Attachments
thing.ged
(2.22 KiB) Downloaded 86 times
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest