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.

Code Snippets / [DBP] 2D World Collision

Author
Message
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 16th Feb 2010 19:04 Edited at: 16th Feb 2010 19:05
My friend and I have always had a dream of making a Commandos reboot or something of a similar gameplay style. This is a very quick and dirty way to handle world collision with game objects and such. It does require some media, and that is attached in a zip.



Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Feb 2010 15:27
Point is incredibly slow.

This is a neat snippet, but really it could be much faster if you used an image plugin, like ImageKit - this would allow you to sample the colours without Point. Point if I recall actually uses another sync, so it's a very nasty little command that you should avoid.

One other option is to take the level image, and make a memblock from it - then you could replace point with a memblock byte check - much much faster than using point() and allows more besides, like checking alpha.

One other thing about this - it would work well in a lemmings or worms type game, so if you used ImageKit it would be so easy to paste circles around for explosions and have destructable maps. It's possible with memblocks too if you wanted to add in the memblock modification stuff - ImageKit would let you have shapes that you can paste onto an image.

Would be very interesting to compare performance between Point and the memblock method.


Health, Ammo, and bacon and eggs!
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 17th Feb 2010 17:45
ooooh, you mention detecting for alpha maps? Would that allow for a light map? ... Somehow? maybe?

flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 18th Feb 2010 02:06
Okay, well I changed it to use memblocks, and the map looks way cooler, and pretty much a lot has changed.

Now there is also pathfinding and destructible environments (sorta). The destructible part is really slow, not sure how I would speed it up.
But anyways, the controls are
-left mouse : moves player to pointer (will get stuck)
-right mouse : destroys walls

code :


Attachments

Login to view attachments
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 7th Apr 2010 22:37
Pretty cool, media for the first is ugly tho lol, jk.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )

Login to post a reply

Server time is: 2024-04-26 18:55:56
Your offset time is: 2024-04-26 18:55:56