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
Thinker11mo 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
BricksAreTastyOP11mo ago
this is what i've done, is this a 2d array?
Thinker
Thinker11mo ago
Are you reusing the same list between draws?
BricksAreTasty
BricksAreTastyOP11mo ago
betwwen draws? probably, theres only one list
Thinker
Thinker11mo ago
Between calls to this method
BricksAreTasty
BricksAreTastyOP11mo ago
its only called once
Thinker
Thinker11mo ago
ah Yeah then idk why this would be an issue
Want results from more Discord servers?
Add your server