I want some asteroids in my game as an attractive background, I have the rocks as active objects, I have them as a ball so they move around the screen, but how to make it so that when they get to the edge of the screen they will come out the opposite side?
Brilliant it works, thanks is it possible to have it so that when it goes off screen, wraps if you like, instead of coming at the same angle when it wraps to randomly change its direction 'when it comes in from the wrap', kind of makes it more interesting.
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
12th September, 2007 at 16:02:54 -
You don't need a "when it comes from the wrap", just randomly change the direction in the same event (but make sure that the direction will not make the ball go directly back to the border it came from, of course).
would this be under the same event insert into the same action, or do you mean under the section with the ticks, stick something in there. Either one I dont see what will change its direction 'after its done its wrap'
I thought in the action area, (that with the ticks, one could just do set direction to, and I clicked all directions.
That to me says,
asteroid leaves play area------------------------- wrap - set direction to
but that just makes it bounce.
not sure if I should have a timer, like leave area, time o.5 second then change direction.
I even tried, object enters frame, then direction, that didnt do it either.
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
12th September, 2007 at 17:48:33 -
Originally Posted by Dean Avanti would this be under the same event insert into the same
asteroid leaves play area------------------------- wrap - set direction to
That. Only make sure to use a calculation for the direction, like "set direction to (current direction-5)+Random(10).
My formula would basically change the object's direction a bit (and randomly), but would never go to an opposite direction.
your talking about the Enter expression to calculate?
I tried copy and pasting exactly what you wrote below
(current direction-5)+Random(10).
I put all the brakets in as well.
tried it without the brakets it doesnt want it. When I mean exactly I mean exactly that, as in copy and paste it.
this is what Ive done, just makes it bounce as its resetting direction as it hits the outside of the level, its not changing direction after it wraps.
http://www.avantivita.com/Dean/DailyClick1.jpg
I thgought it would of been an option to do when entering frame, change direction, and have this after the wrap option, but that didnt work.
So I am quite confused here
Ill go over what I want it to do in case of any misunderstanding.
the asteroid leaves the play area say at the top, it will come out at the bottom, because we used wrap, but it will be going in the same direction, say if it left at 90* at the top, it will come up at the bottom on the wrap but at 90*, well I want when it wraps to come out at a different direction. like say it leaves the screen at 90* it re enters on the other side at a different angle, I dont want the object to always travel at the same direction, it needs to come in after exiting the screen at a new angle.
There's your problem. It was pseudo code, replace "current direction" by actually retreiving the object's current direction.
its an asteroid, its direction could be anything, if its just a ball, thats direction is random, then its direction could be any.
These answers are a bit complex, Ive picked this up this week.
not sure if this is its direction
Dir( "Active" )
but like I say Ive picked this up this week and there is sparce documentation. I need more litral answers, one cant asume I know what people mean when you have been using it for years.
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
13th September, 2007 at 11:58:54 -
That's the better way to do it, really.
Dean, I know its direction could be anything, that's why you randomize it by going max. 10 direction values off of its current direction. Dir("Active") is correct if you (not) named your object "Active".
Leaves play area left------------------------ wrap - set direction (then I click 12-20 on the circle chart)
which was the direction you set in the chart.
I did the same as above for all the others, only with the direction the chart say for which direction it leaves.
This is all that I did, I think it works, not sure if I was supposed to do more than this, it looks like its working, it leaves the level, wraps and is going in a different direction than it was before, so it looks like it works to me, not sure if I was supposed to do more, add more details, or if Im not following the instructions fully and the way you set it makes it work better than how Ive done it.
Great so I got it then, my asteroids work, thanks much appreciated
This is similar to the other background object I want, I have these items, rockets and space stations, that disappear of screen then reappear, at the edge of the screen some other place.
So items leave the screen edge but appear at some other random edge position.
"if object is getting 0 pixels away from windows edge"
- set position to Random
"y" is the height of your frame, so if your frame was 400 pixels high you put "Random(400)" and that'll make it appear at a random point within the height of the game.
If you do the same thing for the x axis too it will appear at a random place anywhere, rather than a random place along the side, which is probably more along the lines of what you'd want - though I don't quite fully understand what it is you require here as you said "other random edge position"
Also instead of saying "Random" or "Random(400)" you can simply put "Random('FrameHeight')" or FrameWidth, which will just save you having to find the width manually, really.
Doing that though will make things appear at a random place on the screen when the object has just gone off of the screen.