The above video goes away if you are a member and logged in, so log in now!

 Would you like to get all the newest Gaming News fromQJ.NET in your email each day? Want to learn more about the team who brings you the QJ news?

## Better Way For Collision In Lua?

This is a discussion on Better Way For Collision In Lua? within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; The way I'm using collision for walls so far is this. I've made a function which is: Code: function wallcollision(x1,x2,y1,y2) ...

 Tweet
1. ## Better Way For Collision In Lua?

The way I'm using collision for walls so far is this. I've made a function which is:

Code:
function wallcollision(x1,x2,y1,y2)
if x > x1 and x < x2 and y > y1 and y < y2 then
x = oldx
y = oldy
end
end
So basicly it creates a square or rectangle area which cannot be walked through by the player. It is called in the game like so:

Code:
wallcollision(0,450,0,14) -- top wall
wallcollision(87,123,0,93) -- top up and down left side
wallcollision(337,374,0,92) -- top up and down right side
wallcollision(0,15,0,271) -- left side wall
wallcollision(0,166,162,196) -- mid wall left to right left side
wallcollision(0,470,243,271) -- bottom wall
wallcollision(224,262,56,97)  -- middle square piece
wallcollision(205,275,95,182) -- middle round piece
wallcollision(447,480,0,280) -- right side wall
The annoying part is that for every single wall I have to manually get the coordinates to make collision for that wall. I'm sure someone has a better and quicker way, if so I'd like to know.

2. something to do with image:height() and image:width()...unless you don't mind manually finding coordinates :)

3. Doesn't tell me much...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

All times are GMT -8. The time now is 05:44 PM.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY