Creations Favorites Posts ID:148588
 ID:148588   Dec 24 2002, 9:37 am I was trying to make an object bounce off walls. It works perfectly at certain angles but at others it really chokes up and the object starts going off at strange angles. I want it to move along the wall one tile before bouncing off. If I ever move on to pixel movement I hope this problem will stop. I so far have not been able to pinpoint the problem. I believe it has to do with my angle rotation because in every wall rotation such as up down left right there is an angle that works and one that starts the object off in a strnage way. Note: Head on collisions are supposed to have it bounce back head on or at an angle. That is why that case is there. Move() oldoldloc = oldloc oldloc = loc ..() Bump(atom/A) //A = wall //oldloc = current location //oldoldloc = old location if(isturf(A) && gtype != "impact") walk(src,null,0) if(!isturf(A)) A = A.loc var/entangle = get_dir(oldoldloc,src) var/bounce = turn(entangle,180) var/bounceang if(bounce in list(NORTH,SOUTH,EAST,WEST)) bounceang = turn(bounce,pick(45,0,-45)) else bounceang = turn(bounce,-90) step(src,turn(bounceang,-45)) sleep(2) // world << entangle // world << bounce // world << bounceang // world << turn(bounceang,-45) // world << "NW:[NORTHWEST]" walk(src,bounceang,2)
 #1 Dec 24 2002, 11:59 am Are you designing this for tile-based movement only (as in, a ball only moves a tile at a time), or is it meant for smooth movement like in pool? Tile-based bounces are a lot easier to set up of course. Smooth movement physics are murder, although you might do a little better if your balls are merely circular. Lummox JR
 #2 Dec 24 2002, 1:20 pm In response to Lummox JR (#1) tile based. I really just want this to be simple. The main goal is to have either perfect richochete off the wall when at an angle or head on have it jump back at you with a slight variation in direction.