The Daily Click ::. Forums ::. Klik Coding Help ::. Object leave screen, come back opposite side
 

Post Reply  Post Oekaki 
 

Posted By Message

Dean Avanti



Registered
  01/11/2006
Points
  130
12th September, 2007 at 10:10:40 -

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?

Just like in that old asteroids arcade game


 
http://www.avantivita.com
Video game developers and home of video game development assets.

Dean Avanti



Registered
  01/11/2006
Points
  130
12th September, 2007 at 14:23:50 -

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.

Image Edited by the Author.

 
http://www.avantivita.com
Video game developers and home of video game development assets.

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
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).

 
Old member (~2004-2007).

Dean Avanti



Registered
  01/11/2006
Points
  130
12th September, 2007 at 17:08:31 -

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.

Any Ideas on this, what can I do here.

Image Edited by the Author.

 
http://www.avantivita.com
Video game developers and home of video game development assets.

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
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.

 
Old member (~2004-2007).

Dean Avanti



Registered
  01/11/2006
Points
  130
12th September, 2007 at 18:33:50 -

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.

Image Edited by the Author.

 
http://www.avantivita.com
Video game developers and home of video game development assets.

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
13th September, 2007 at 06:21:39 -


Originally Posted by Dean Avanti
I tried copy and pasting exactly what you wrote below


There's your problem. It was pseudo code, replace "current direction" by actually retreiving the object's current direction.

You can put multiple actions in one condition, just add it to the "when leaving play area" part.

Image Edited by the Author.

 
Old member (~2004-2007).

Dean Avanti



Registered
  01/11/2006
Points
  130
13th September, 2007 at 07:49:49 -

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.

Image Edited by the Author.

 
http://www.avantivita.com
Video game developers and home of video game development assets.

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
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".

 
Old member (~2004-2007).

Dean Avanti



Registered
  01/11/2006
Points
  130
13th September, 2007 at 17:44:04 -

This is what I did.

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.

Have I done it correctly?

 
http://www.avantivita.com
Video game developers and home of video game development assets.

Phredreeke

Don't listen to this idiot

Registered
  03/08/2002
Points
  4504

You've Been Circy'd!VIP MemberPS3 Owner
13th September, 2007 at 18:00:36 -

Originally Posted by Phizzy [Ectoprods]
Okay then, I'll give you a really simple method with little words and OEKAKI!!!1111

Image

Phizzy, you're the next Da Vinci!

 
- Ok, you must admit that was the most creative cussing this site have ever seen -

Make some more box arts damnit!
http://create-games.com/forum_post.asp?id=285363

Dean Avanti



Registered
  01/11/2006
Points
  130
13th September, 2007 at 18:37:31 -

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.

How could I do this?

 
http://www.avantivita.com
Video game developers and home of video game development assets.

Tim

I'm on here way too much

Registered
  25/08/2006
Points
  132

You've Been Circy'd!Clickzine StaffSilverNova MemberVIP MemberTurtle Power!Evil klikerWii OwnerHero of TimeGhostbuster!Pokemon Ball!
14th September, 2007 at 16:38:05 -

You can say:

"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.

 
http://www.SilverNova.co.uk


Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
14th September, 2007 at 17:37:12 -

That's not the effect he's looking for at all though tim.

 
Craps, I'm an old man!

Tim

I'm on here way too much

Registered
  25/08/2006
Points
  132

You've Been Circy'd!Clickzine StaffSilverNova MemberVIP MemberTurtle Power!Evil klikerWii OwnerHero of TimeGhostbuster!Pokemon Ball!
14th September, 2007 at 17:39:02 -

Never mind then lol

 
http://www.SilverNova.co.uk


AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
14th September, 2007 at 17:40:33 -

He wants them to wrap like they do in the classic Asteroids game. Then to change direction by a few degrees.

 
.

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
14th September, 2007 at 17:46:42 -

lol, it happens.

 
Craps, I'm an old man!

Tim

I'm on here way too much

Registered
  25/08/2006
Points
  132

You've Been Circy'd!Clickzine StaffSilverNova MemberVIP MemberTurtle Power!Evil klikerWii OwnerHero of TimeGhostbuster!Pokemon Ball!
14th September, 2007 at 19:22:05 -

OH! Ah well, Phizzy's got it covered.

 
http://www.SilverNova.co.uk


Dean Avanti



Registered
  01/11/2006
Points
  130
15th September, 2007 at 12:04:38 -

Wow it works, thats pretty cool, thanks phizzy

I see how it works, its pretty clever, what does this part do though.

Event:
- Powerup Alterable Value A > 0
Action:
--> Set Alterable Value A to 0.

I see how the rest works, that part I dont understand what it does to it.

 
http://www.avantivita.com
Video game developers and home of video game development assets.

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
15th September, 2007 at 12:08:00 -

It makes sure that the event doesn't keep happening constantly, otherwise it would keep randomly switching position because Value A isn't 0.

 
Craps, I'm an old man!
   

Post Reply



 



Advertisement

Worth A Click