Posted By
|
Message
|
W3R3W00F Drum and Bass Fueled Psycho
Registered 08/11/2008
Points 374
|
21st June, 2010 at 02:27:50 -
...when out of boundaries? I've made an arrow that should point to the player when the player leaves the frame. Problem is, I'm awful at coding and it's either hit or miss with me. Anybody know how this would be coded?
As always, thanks in advance!
An old and washed up once-kid
|
OMC What a goofball
Registered 21/05/2007
Points 3516
|
21st June, 2010 at 02:33:37 -
Player X Position is less than 0
OR
Player X Position is greater than frame width
OR
Player Y Position is less than 0
OR
Player Y Position is greater than frame height
>> Point arrow
If you have a scrolling camera, do this: Player X Position is greater than Camera X Position + Half of the frame width. Etc.
Should hopefully do!
|
W3R3W00F Drum and Bass Fueled Psycho
Registered 08/11/2008
Points 374
|
21st June, 2010 at 03:22:06 -
That's not really what I meant, my bad. Apologies for not being more specific...
First off, the camera does scroll, if that changes anything (I don't think it will, but you never know.) What I'm trying to achieve is to have the arrow point in the direction of the player, and always stay on the edge of the frame. (E.g: The player is to the left of the frame and can't be seen, so the arrow would be on the left side of the frame and of course, pointing left, and always equal the player's Y co-ordinate. Plus, reappear. If the player is in the frame, the arrow will be invisible. This would be the same for the right side, but for the top and bottom sides, it's just be the X co-ordinate instead of the Y.
If you need more specifications, I'll try my best to explain it better.
Edit: Specification fix, yes.
Edited by W3R3W00F
An old and washed up once-kid
|
nim
Registered 17/05/2002
Points 7234
|
21st June, 2010 at 07:36:01 -
Use a simple atan2 "look at" expression to make the arrow "point to" the player from the centre of the window ((X Left Frame + Window width/2),(Y Top Frame + Window height/2)), and set the distance (radius) to the distance between them. This will make the arrow more or less be at the same position as the player object. Then add these 4 conditions:
X("Arrow") is less than [X Frame Left] > Set X("Arrow") to X Frame Left
X("Arrow") is greater than [X Frame Right] > Set X("Arrow") to X Frame Right
Y("Arrow") is less than [Y Frame Top] > Set Y("Arrow") to Y Frame Top
Y("Arrow")is greater than [Y Frame Bottom] > Set Y("Arrow") to Y Frame Bottom
I can't make you an example right now but I've done this before and it worked. It'll stick a little in the corners but I think that's unavoidable.
//
|
nim
Registered 17/05/2002
Points 7234
|
21st June, 2010 at 08:50:33 -
Here's a thing what I maked.
http://www.afroboss.com/misc/outsideWindowPointer.zip
I hope it's what you're looking for!
//
|
Del Duio Born in a Bowling Alley
Registered 29/07/2005
Points 1078
|
21st June, 2010 at 16:51:13 -
I did this same thing with ODW. When you play as the whore you can summon a pet, and the spider is slow enough so that he'd constantly go off the play screen so an arrow that appears up in the upper left-hand corner that points to his general direction was needed.
It's really easy. You just make the arrow point in 8 different directions (stopped animation, different arrows drawn for the 8 directions) and set it somewhere on your screen. Make sure it does NOT follow the frame so that it always stays put.
Then have something like this:
---
Always -> arrow is invisible
If player (is out of your play field's dimensions) -> have the arrow look in the direction of the player
+make the arrow visible
---
And that's it! I was really surprised how easy it was to do, and it's very helpful for some games. Good luck.
Edited by Del Duio
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
|
W3R3W00F Drum and Bass Fueled Psycho
Registered 08/11/2008
Points 374
|
21st June, 2010 at 18:22:22 -
Great, thanks Nim! This'll work perfectly.
And of course, Thanks, OMC and Del Duio!
An old and washed up once-kid
|
Jason Orme Using Klik Products Since 1998
Registered 24/05/2002
Points 960
|
29th June, 2010 at 18:12:34 -
is there anyway of making this work for when multiple baddies are outside the screen?
Example, the players scrolls around the screen and multiple enemies are somewhere else on the map, the arrows point to them until they are visable on screen.
Edit: nevermind, sorted.
Edited by Jason Orme
www.jsofts.com
|
|
|