Pacman-esque game in c# raylib. Help with optimisation/collision

Im making a game for my class project and i've stumbled onto a problem with my level design. Essentially the way i made my level is by creating and generating rectangles from a list[,] array(? i think its called that) for every wall in the level. Only problem is that this method ends up generating like 100 rectangles and fries the computer. Additionally, i have not found a method to add collision between these rectangles and my character (also a rectangle). i can provide a github repository if needed for the code.
7 Replies
Thinker
Thinker9mo ago
Pacman takes place on a consistent grid, why not represent the walls as a single 2d array? 100 rectangles should absolutely not be an issue unless you're using an extremely inefficient representation A rectangle at its simplest should literally be 4 integers
BricksAreTasty
BricksAreTasty9mo ago
this is what i've done, is this a 2d array?
Thinker
Thinker9mo ago
Are you reusing the same list between draws?
BricksAreTasty
BricksAreTasty9mo ago
betwwen draws? probably, theres only one list
Thinker
Thinker9mo ago
Between calls to this method
BricksAreTasty
BricksAreTasty9mo ago
its only called once
Thinker
Thinker9mo ago
ah Yeah then idk why this would be an issue
Want results from more Discord servers?
Add your server