Help with multiball breaklout for the course cs50 intro to Game Development
Posted: Sun May 10, 2020 2:22 pm
My 13-year-old son is doing a course in Lua (love 2d). The course is terrible in that it doesn’t give any course material nor does it really explain anything.
The course is called:
cs50 intro to Game Development
It’s like you need to complete the course, in order to know how to complete the course.
My son is finding Lua hard because there's a lot to learn before you can change someone else’s code. So many functions and calls, classes, states etc. He has completed two assignments and is stuck on the third. To make a powerup for a game (which he has done with collision detection too) and introduce a second ball.
We are stuck creating a second ball and processing it.
We already figured out that the best way to handle this is probably with a table, so we can create a code loop for collision and render aspects of the ball to apply to multiple balls whose data we store in a table. But he is struggling with the structure of how the ball data is handled (variables are created with data passed to a function, but he and I don’t understand the process of how those these variables are set up and so we can’t create the table needed for the power-up). I wondered if any kind person would be prepared to help us through it?
Here is a tiny snippet of the collision code for the ball:
What we don't know how to do is create a table variable so that we can do something like:
and then adjust all code to process our multi-ball table, like this (but we are unsure of syntax).
So that the loop will process all ball instances.
The main problems we face are: We don't understand all the data handled by the self.ball variable.
We don't quite know how to set up the table with the same data as self.ball
(something like)
Sorry it's IS a general lack of understanding about LUA and how variable and tables work, but we are trying hard to get to the point where this is clearer (but the course does not help at all).
FYI. The ball parameters are passed into self.ball in this manner:
We don't even really understand how that function is called and what data is passed through params, it's a severe lack of understanding that the course fails to help with, through resources, course materials or support.
We have tried very hard to both upskill enough to solve this but we are too noob.
I found this on Reddit which talk about the exact problem and the solution (similar to the way we want to implement it, but we just need some guidance if anyone can).
https://www.reddit.com/r/cs50/comments/ ... akout_for/
Any help every so greatly appreciated.
The course is called:
cs50 intro to Game Development
It’s like you need to complete the course, in order to know how to complete the course.
My son is finding Lua hard because there's a lot to learn before you can change someone else’s code. So many functions and calls, classes, states etc. He has completed two assignments and is stuck on the third. To make a powerup for a game (which he has done with collision detection too) and introduce a second ball.
We are stuck creating a second ball and processing it.
We already figured out that the best way to handle this is probably with a table, so we can create a code loop for collision and render aspects of the ball to apply to multiple balls whose data we store in a table. But he is struggling with the structure of how the ball data is handled (variables are created with data passed to a function, but he and I don’t understand the process of how those these variables are set up and so we can’t create the table needed for the power-up). I wondered if any kind person would be prepared to help us through it?
Here is a tiny snippet of the collision code for the ball:
Code: Select all
if self.ball.x + 2 < brick.x and self.ball.dx > 0 then
-- flip x velocity and reset position outside of brick
self.ball.dx = -self.ball.dx
self.ball.x = brick.x - 8
Code: Select all
for i= 1 ,no_of_balls do
Code: Select all
if self.ballList[i] + 2 < brick.x and self.ballList[i+3] > 0 then ....
The main problems we face are: We don't understand all the data handled by the self.ball variable.
We don't quite know how to set up the table with the same data as self.ball
(something like)
Code: Select all
self.ballList = {}
table.update (self.ballList, self.ball.x, self.ball.y, self.ball.dx, self.ball2.x, self.ball2.y, self.ball2.dx)
FYI. The ball parameters are passed into self.ball in this manner:
Code: Select all
function PlayState:enter(params)
self.ball = params.ball
We have tried very hard to both upskill enough to solve this but we are too noob.
I found this on Reddit which talk about the exact problem and the solution (similar to the way we want to implement it, but we just need some guidance if anyone can).
https://www.reddit.com/r/cs50/comments/ ... akout_for/
Any help every so greatly appreciated.