The Daily Click ::. Forums ::. Klik Coding Help ::. XYpos on corners of visible play area? Wrap a virtual playfield?
 

Post Reply  Post Oekaki 
 

Posted By Message

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
25th May, 2014 at 25/05/2014 00:38:00 -

I'm creating an overhead asteroid shooter and I'm having trouble trying to figure out how to test X/Y values in the corners of the visible play area. I have a virtual resolution of 4,000x4,000 and a level resolution of 500x320 so the spaceship player active can fly around. I don't want to spawn asteroids all over the 4,000x4,000; just within the visible 500x320 area surrounding the player active. Once the asteroids float off of the borders of the visible play area, I want to destroy them. Any way to test for the X/Y position on the very corners of the visible playfield anywhere within the 4,000x4,000 virtual resolution?

The other goofy thing I notice is that when I test whether the spaceship player active leaves the edge of the playfield and I try to wrap it's position, the event triggers when the player spaceship leaves the 4,000x4,000 virtual play area, but then the camera refuses to reposition and the ship disappears. I've also tried resetting the X/Y positions of the spaceship to the opposite side of the virtual level, then centering camera X/Y on the same position, but the game behaves the same way. Urp.

I think this 'virtual level resolution' thing is really screwing me up.

I've included the MFA. I commented the relevant bits. It doesn't use any extensions. Halp, plox?
https://onedrive.live.com/redir?resid=E2D87E65CC574F02%21123

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
25th May, 2014 at 25/05/2014 19:28:26 -

Is there a way for you to check the absolute distance (like, pixel-measured radius) with the player ship as the center point? I think there's a way to use the Advanced Direction Calculator extension to do that. Check Castles of Britain for an example of what you may need to do.

If it works, simply destroy a space rock that's beyond the permitted radius of the player ship. Additionally, destroy any space rock that goes beyond the edges of your 4Kx4K frame.

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
25th May, 2014 at 25/05/2014 21:39:35 -

UPDATE: First here is the fixed MFA: https://mega.co.nz/#!Ah5ASBBL!IdSydm_9gM1S2ZbfhMz_tFqvzdUOnkcDbzbuHrfMi60
I found the issue with your ship not wrapping. You had the gameplay layer's Scrolling coefficient set to 0.3. It should always be set to 1.
I also added seamless scrolling. Check it out!

Don't use virtual resolution. Just set the frame size to 4000x4000.

To use the visible edges in your calculations for positioning objects, or destroying objects use the following in the expression editor:

Image

Another useful thing for checking the position of objects relative to the visible viewing area is the following condition:

Image

You can use this to destroy asteroids that are too far from the viewing area. Just use a negative number.

Edited by UrbanMonk

 
n/a

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
26th May, 2014 at 26/05/2014 07:00:27 -

Eghads... early on I had four layers; the forth was just to test stuff. As I kept developing I started removing the unnecessary, so I moved everything from the fourth layer down to the third without realizing that the third layer was already set up as a parallax backdrop. -_-

Thanks for the seamless scrolling! I was trying to pull off the same effect earlier by detecting the ship in the last 250px X and 160px Y of the playfield then repositioning them at 250px X and 160px Y at the opposite sides respectively. It wouldn't work because of that damn scrolling coefficient I overlooked, but this seems to do the same thing with less events. Yay!

@SMR - I'm eventually going to need to calculate distance between actives, but this time around I just added an Alterable Value named 'decay' to every active I needed to disappear for much resource win, then I added all the active objects to a qualifier group.
Always : (Group.1) sub 1 from Alterable Value B (decay)

Group.1 Alterable Value B <= 0: (Group.1) Destroy.


I was noticing that despite Urban's suggestion of using "is 'Active' getting close to window's edge?", most of my actives were destroying as soon as they left the visible playarea, but there were leftovers so I tweaked the decay value on a few of them and that did the trick. Used to be that playing for five minutes maxed out the 500 object level limit, but now never have more than 30 actives at any time.

Still very, very early on. Eventually, this is going to turn into a multi-mode space shooter with RPG elements. Progress is... meh; but I have most of the side-scrolling mode done, a few galactic towns half-finished, and a couple of experimental mode-7 levels nearly complete. It's ambitious, but... shut up!

Thanks for all the help, y'all.
I'm prone to forgetting where I last left off, so I'm sure I'll be in here next time I fubar some property that prevents expected execution and forget about it. Next time, I'll try to keep to asking a technical question. lol

Edited by The_Antisony

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
26th May, 2014 at 26/05/2014 16:54:10 -

Running a distance calculation constantly for the sake of cleaning up old actives and increasing performance is counterproductive from my experiences.

Its better to use the built-in distance from edge as much as you can.

Glad I could help!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click