Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
Collision detection engine
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default Collision detection engine - 02-26-2010, 10:45 PM

Welcome to the collision engine! Please feel free to use this in your games, as long as you give me credit!

Required Sections:
  • Collision method, and event calling it.
  • World variables.
  • All objects referenced to by the objects list.
  • A cylinder named "cylinder".
Known Bugs:
  • Main cylinder hovers. Fixed as of 1.1.
  • Cylinder might re-size erratically. Can be fixed by putting cylinders closer together.
  • Main cylinder appears to vibrate while against a wall. This is the location being corrected. It can be reduced by putting cylinders closer together.
Todo:
  • Add support for different types of obstacles. (i.e. squares, spheres, etc.)
  • Less memory intensive methods. This is to leave more memory with other methods.
  • Get a balanced time and distance for collision data setting. This will help to reduce vibration on the main cylinder, while hopefully not running the method too much. It is memory intensive to check every object!
Recommendations:
  • The objects that you collide with can be invisible! Use Other objects for visuals, and leave the work to the cylinders!
  • The program fixes collision data every quarter second. Setting the world variable "break" will override this, and cause the data to be refreshed immediately. This is good for when you change scenes.
Current Version:
Collision detection 1.3.a2w

Current Engine(No other stuff):
Collision Engine 1.4.a2w

Last edited by zonedabone; 03-18-2010 at 03:42 PM.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 02-26-2010, 10:55 PM

Wow, this is very nice and very smooth (although the coding doesn't really make sense to me, but hey, if it works then thats all that really matters! )

However, this is an almost flawless engine. There is only 1 glitch that I have found so far, but it is a major one (sorta). Ok so you know there is a spot in top right that you can escape from the cylinder prison, but then go to the top left, once you are outside, to that gap that you can almost get into. If you wiggle around a bit, you find that you can somehow wiggle over the gap, making you hover slightly, allowing you to get past the cylinders and the collision detection does not work from then on. (Maybe I should be a video game tester...)


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default 02-26-2010, 11:05 PM

Actually, I'm already working on a new engine that uses trig to calculate horizontal distance. Furthermore, you can just add another cylinder in that space. You know that you can move the cylinders, add more, and play as much as you want, so long as the list contains all of the cylinders? It's awesome!


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 02-26-2010, 11:11 PM

Yes, but if you run into a glitch like the one I did, the whole concept will be for nothing because the collision detection will not work anymore. If you add another cylinder there, then you may be able to do it in another part of the game.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default 02-26-2010, 11:43 PM

Guess what? I added a method to the world. Every second, it runs what I call a "Maintenance script." It resets the vertical position of your cylinder! I can also add other things to it. I have it reset the positions of the others at the beginning, since they never move. Just remember that you can have as many of these as you want! I'm thinking of adding a side script that reduces the load on the main unit, though. I wouldn't be good to have 100 cylinders if 90 of them are obviously out of reach! Maybe this could be included in the maintenance script!


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default 02-27-2010, 12:01 AM

Breakthrough! The higher up on the events list an event is, the higher priority it is! That's great! I'll be sure to keep my collision there, and my maintenance at the bottom


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
Niteshifter
Guest
 
Status:
Posts: n/a
Default 02-27-2010, 12:06 AM

Quote:
Originally Posted by zonedabone View Post
Guess what? I added a method to the world. Every second, it runs what I call a "Maintenance script." It resets the vertical position of your cylinder! I can also add other things to it. I have it reset the positions of the others at the beginning, since they never move. Just remember that you can have as many of these as you want! I'm thinking of adding a side script that reduces the load on the main unit, though. I wouldn't be good to have 100 cylinders if 90 of them are obviously out of reach! Maybe this could be included in the maintenance script!
I might have an idea on how this could be achieved. Have the method find every object that is within a reasonable distance put into a "listen for" list at the beginning. Then after the maintenance script is run, it will iterate through the "listen for" list to remove objects out of range and add the objects within range (that is, if they are in the main list and not already in the "listen for" list to begin with). Then, have the collision detector use the "listen for" list instead of the main list.
   
Reply With Quote
Old
jediaction
Senior Member
 
jediaction's Avatar
 
Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
Default 02-27-2010, 06:39 PM

Quote:
Originally Posted by Dameria View Post
Wow, this is very nice and very smooth (although the coding doesn't really make sense to me, but hey, if it works then thats all that really matters! )

However, this is an almost flawless engine. There is only 1 glitch that I have found so far, but it is a major one (sorta). Ok so you know there is a spot in top right that you can escape from the cylinder prison, but then go to the top left, once you are outside, to that gap that you can almost get into. If you wiggle around a bit, you find that you can somehow wiggle over the gap, making you hover slightly, allowing you to get past the cylinders and the collision detection does not work from then on. (Maybe I should be a video game tester...)
I dont get it either so it cant help me make cool games with collisoin. Sorry, but good job!!!!


Website: www.salokingames.com
FaceBook: www.facebook.com/SalokinGames

Last edited by jediaction; 02-28-2010 at 11:40 AM.
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 577
Join Date: Nov 2008
Location: In the interwebs
Default 02-27-2010, 06:41 PM

It tests proximity, and then moves the main object accordingly. I'll try to make a version with comments, although it will run crazy slow with them there.


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
All I Mean...
Old
King Gamer(gorit)
Guest
 
Status:
Posts: n/a
Default All I Mean... - 02-27-2010, 11:41 PM

All I mean is that functions run faster no matter where the method is in the event area. Alice executes functions with a higher priority than any other methods. It is not always a necisary thing to do but if you do it it can create problems when hundreds of items are within the area it is in. It apears in your demo world that there is a bit of shaking.

Last edited by King Gamer(gorit); 02-27-2010 at 11:46 PM.
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.