GoldenPhoenix
April 16th, 2006, 13:57
Just something really quick thats been giving me problems. When programming in lua, how would I make a unpassable object, like a rock or something, in an RPG styled game. I want the player to stop when he touches a color,for example,
red = Color.new(255,0,0)
block = Image.createEmpty(X,Y);
block:clear(red)
Thanks :D
PSPHax0r9
April 19th, 2006, 05:07
I think what you're looking for is some collision detection. Here is an example of a good collision tutorial: http://forums.qj.net/showthread.php?t=47248&highlight=collision
Now all you would have to do is add an "if" statement saying something like
if blockx == playerx then playerx=playerx end
That way you would have different variables for the X and Y values of the block, and the X and Y values of the player. Once they are equal, the player will remain in that same x position until blockx ~= playerx
Powered by vBulletin® Version 4.2.3 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.