Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 2D Sliding Collision - How do I do it?

Author
Message
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Jul 2015 13:35
Hello,
Thanks to Humble Bundle, I've just purchased AGK2 and have started my first AGK2 game. (I've used AGK1 since release.)

I'm trying to create a 2d top down scroller, but can't figure out how to implement 2D sliding collision. I have my walls set in a sprite group, but I don't know how to create a sliding collision routine similar to the 3D SphereSlide command.

Does anyone have and pointers/code they can share?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jul 2015 13:47
Hi Mobiius! Long time no see

You can detect collision or use 2D Physics to simulate it. There aren't any manual commands I have seen for sliding collision. You might be interested as an experienced DBPro user in the 3D collision code which is fully based on sparky's collision. You could:

1-Use hidden 3D objects and 'sparky's'
2-Use 2D physics (I would)
3-Use your own sliding code based on the 2D collision detection code but that would probably take the longest and be hardest to implement

Using AppGameKit V2 Tier 1
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Jul 2015 13:50
Was hoping to not have to use the physics as it seems overkill for my needs.

I might actually create my own sliding collision code, I've just had a quick think and it should be too difficult.

Gimme 5 minutes.... lol

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Jul 2015 14:20 Edited at: 15th Jul 2015 14:50


Ok, I have this. It makes collision work, but no sliding. I may have to write my own raycasting functions.. Gimme another 5 minutes!

(The above code needs you to create 1 sprite to be your player, stored as Player.SpriteNo.

Type tPlayer
SpriteNo
EndType
Global Player As tPlayer


And a number of sprites set up as a 'wall')

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Jul 2015 14:50 Edited at: 15th Jul 2015 14:50


2D sliding collision complete. No Physics object required

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jul 2015 15:41
There ya go... good to have you around!

Using AppGameKit V2 Tier 1
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Jul 2015 16:09
Glad to be back!

Login to post a reply

Server time is: 2024-11-16 18:12:50
Your offset time is: 2024-11-16 18:12:50