Community
Message Board

Chat room - users
Game Over
( 394431 downloads)
Work In Progress
( 523201 downloads)
Links

Code Exchange
Downloads
Tutorials
Add to Favourites

Submit news

DIV ARENA FORUMS
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: Collisions between scroll and screen processes
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 18-4-2016 at 10:09 PM
Collisions between scroll and screen processes


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:




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
iWizard
Loyalty Card Holder
******


Avatar


Posts: 159
Registered: 26-2-2016
Member Is Offline


[*] posted on 19-4-2016 at 08:54 AM
If this requires a hack solution then I'm your man!


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.
View user's profile View All Posts By User
MikeDX
DIV Nerd
*********


Avatar


Posts: 8388607
Registered: 25-2-2016
Member Is Offline


[*] posted on 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...
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 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!)




~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User
BreadCaster
Loyalty Card Holder
******


Avatar


Posts: 321
Registered: 2-3-2016
Member Is Offline


[*] posted on 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



~*~ Princess of Pies and Pastries ~*~
View user's profile View All Posts By User

  Go To Top

Powered by XMB
XMB Forum Software © 2001-2012 The XMB Group
[Queries: 18]