Using variables from another file?
Posted: Wed Jan 13, 2016 5:43 pm
Hey all,
I am trying to make a Breakout clone involving an entity system, however I can't figure out how to check for collision between the ball and the paddle. I currently have a require statement at the top of ball.lua and the lines of code that should cause the ball to bounce off of the paddle commented out. When I run this, it causes the ball to spawn at the correct location (x and y values passed in the ents.Create() function in main.lua) but the ball does not bounce off the paddle.
When the require statement and the lines are uncommented and run, the ball will only spawn in the top right corner of the screen and will collide with what looks like an invisible "paddle" at the position where the x and y coordinates are passed into ents.Create() which should be the spawn position of the ball.
How would I be able to get the x and y position of the paddle from the paddle.lua file to check for collisions in the ball.lua file without using global variables?
I am trying to make a Breakout clone involving an entity system, however I can't figure out how to check for collision between the ball and the paddle. I currently have a require statement at the top of ball.lua and the lines of code that should cause the ball to bounce off of the paddle commented out. When I run this, it causes the ball to spawn at the correct location (x and y values passed in the ents.Create() function in main.lua) but the ball does not bounce off the paddle.
When the require statement and the lines are uncommented and run, the ball will only spawn in the top right corner of the screen and will collide with what looks like an invisible "paddle" at the position where the x and y coordinates are passed into ents.Create() which should be the spawn position of the ball.
How would I be able to get the x and y position of the paddle from the paddle.lua file to check for collisions in the ball.lua file without using global variables?