Ontogenesis Posted October 17, 2013 Share Posted October 17, 2013 So I've decided to just get on with a 2D game project that's been on my mind a lot recently.I using LOVE, a Lua 2D engine.Unfortunately, I've run into a problem already with a piece of code that highlights grid squares. Full details can be found here: https://love2d.org/forums/viewtopic.php?f=4&t=72078 I was wondering if any competent coders can identify the source of my problem? Basically if I include an if function for the mouse over, the highlighting doesn't work. However, if I take it out, it works fine. But the line of code that switches the if statement between true and false is in the same bit it gets the co-ordinates to draw the highlighting tile... so it must be able to run the chunk fine, I don't understand why it doesn't work. This is the problem area:--compares mouse x and y to the x and y grid co-ordinates stored in a table if ((x >= gx) and (x <= gx+s)) and ((y >= gy) and (y <= gy+s)) then highlight.ini = true --enables drawing highlight.x = gx highlight.y = gy else highlight.ini = false --disables drawing end--in the draw callbackif highlight.ini thenlove.graphics.draw(high, highlight.x, highlight.y)end^ This doesn't work. But this does:--compares mouse x and y to the x and y grid co-ordinates stored in a table if ((x >= gx) and (x <= gx+s)) and ((y >= gy) and (y <= gy+s)) then highlight.ini = true highlight.x = gx highlight.y = gy else highlight.ini = false end--in the draw callback--if highlight.ini thenlove.graphics.draw(high, highlight.x, highlight.y)--endAhhh Link to comment Share on other sites More sharing options...
Ontogenesis Posted October 17, 2013 Author Share Posted October 17, 2013 I was just being stupid - as I suspected.Now solved: https://love2d.org/forums/viewtopic.php?f=4&t=72078 Link to comment Share on other sites More sharing options...
RoboMat Posted October 20, 2013 Share Posted October 20, 2013 I hope you know that now you'll have to post your project in the indie scene section so we can track your progress Link to comment Share on other sites More sharing options...
Ontogenesis Posted October 20, 2013 Author Share Posted October 20, 2013 I hope you know that now you'll have to post your project in the indie scene section so we can track your progress Well, I figured as I can now highlight squares in a grid, that it's time for Kickstarter. RoboMat 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now