DIV ARENA FORUMS

Collisions between scroll and screen processes

BreadCaster - 18-4-2016 at 10:09 PM

Hey all. It's been an awfully long time since I've done any programming at all, in DIV or anything else :p

Yet I'm absolutely certain I asked this question before at some point: can you have collisions between ctype c_screen (default ctype) and c_scroll processes/processes on the scroll?

It seems like such a simple thing yet I can't find anything on it. Any advice appreciated, I'm sure I can hack a solution of some kind together if nobody can assist, it just won't be as elegant :smilegrin:

If this requires a hack solution then I'm your man!

iWizard - 19-4-2016 at 08:54 AM

Pseudo code:
Code:
Process scroll_mouse(graph) Begin ctype = c_scroll; Loop x = scroll[0].camera.x + mouse.x; y = scroll[0].camera.y + mouse.y; frame; End End

That should follow mouse in "scroll space". I warn again; it's pseudo code, so check the manual for exact variable names (and what they do). If scroll.camera.x points to viewport (that is scroll's region, if that was a thing) center then you need to subtract viewport width/2 from x and height/2 from y.

MikeDX - 19-4-2016 at 10:56 AM

You can also modify the process x/y vars, check the collision and then reset them before the frame;

Code:
ox = x; oy = y; x+=scroll[0].x0; y+=scroll[0].y0; if(collision(blah)).... end x = ox; y = oy; frame;



This might also be affected by the region, but I can't remember off hand...

BreadCaster - 19-4-2016 at 06:35 PM

Quote: Originally posted by iWizard  
Pseudo code:
Code:
Process scroll_mouse(graph) Begin ctype = c_scroll; Loop x = scroll[0].camera.x + mouse.x; y = scroll[0].camera.y + mouse.y; frame; End End

That should follow mouse in "scroll space". I warn again; it's pseudo code, so check the manual for exact variable names (and what they do). If scroll.camera.x points to viewport (that is scroll's region, if that was a thing) center then you need to subtract viewport width/2 from x and height/2 from y.


Yes this was a similar thing to what I was thinking! I've got my main player coordinates stored in global variables for the purpose of AI routines (I find using a lot of get_id assigned to variables often has the issue of making the game crash if that process suddenly ceases to exist so I avoid it where practical) but this is a better solution methinks - wish I'd come up with this idea. Thanks Wiz! :D

So, just to be a pedant: does anybody actually know if collisions between scrolling and non-scrolling processes is impossible? Just for future reference ^^;

Also Mikey - thank you but that solution is unlikely to work in this context, as it's the scrolling processes that are detecting collisions with the non-scrolling process, not the other way around (I could use variablename=collision(type bla) and then use variablename.somelocalvariablerepresentingifcollidedornot i guess :P but it's a little roundabout!)

BreadCaster - 19-4-2016 at 07:29 PM

Yep, works. Now Cybercrisis has smart bombs (well, "carpet bombing" which basically functions the same). Thanks guys! :D