![]() |
|
[Lua] Any idea why this keeps going out of bounds LOVE2D - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5) +---- Thread: [Lua] Any idea why this keeps going out of bounds LOVE2D (/showthread.php?tid=4137338) |
Any idea why this keeps going out of bounds LOVE2D - Toph Beifong - Mar 27, 2014 Basically i have an image which is repeated 5 times and i am trying to make it so they cant go out of the window but no matter what i try i just cant get it to work. Any help: This is my full code, originally it was going to be a Snake game but the smooth change in direction absolutly baffled me. So at the min it is just 5 bxes inline that more up,down, left, right. PHP Code * - Aelustelin - Mar 27, 2014 What is broken? Just that its not bounded by the window or? Just make it so it checks x and y against 0 and scrw or scrh (when applicable) every time a move happens. Then if it finds the move went out of bounds end the game. * - .eXe - Mar 27, 2014 The way I do it in Corona is create 4 invisible objects (or images) that are on the outside walls, then have a function then when it comes in contact with the snake, it reverses the velocity to turn it around or kills it and ends the game. Could you not do something like that? * - Toph Beifong - Mar 27, 2014 (Mar 27, 2014 05:09 AM)Evil.eXe Wrote: The way I do it in Corona is create 4 invisible objects (or images) that are on the outside walls, then have a function then when it comes in contact with the snake, it reverses the velocity to turn it around or kills it and ends the game. Yer hadn't thought about using a system like that, so far i'd just been using a set width and is the end of the snake touched it it would stop * - .eXe - Mar 27, 2014 (Mar 27, 2014 06:24 AM)Mr. P-teo Wrote: Yer hadn't thought about using a system like that, so far i'd just been using a set width and is the end of the snake touched it it would stop Give it go! Let me know if it works. |