(Feb-18-2019, 09:14 PM)andrerocha1998 Wrote: I also check the Rect functions. My understanding is that for the Rect collision functions to work, snake.body should be a string of Rects, instead of center.points. This would mean I'd have to change the whole generation and movement functions.Rect have center attributes.
Quote:x,yYou wouldnt really have to do it for food as the head of the snake would be the only thing colliding first with food. So you would only have to worry about the snake intersecting on itself. Ive never made a snake game, so i am not sure how the best approach would be. If its a small game, the way it works is good enough.
top, left, bottom, right
topleft, bottomleft, topright, bottomright
midtop, midleft, midbottom, midright
center, centerx, centery
size, width, height
w,h
(Feb-18-2019, 09:14 PM)andrerocha1998 Wrote: The controls seem unresponsive at times because of the delay, however. This didn't happen when I controlled the speed via FPS. Any way to fix this?I do not know what you mean? When i run it it seems fine. Can you explain?
(Feb-18-2019, 09:14 PM)andrerocha1998 Wrote: On an unrelated note, from the documentation you linked, sometimes classes are defined with (object), (something) or (). (something) I understand is to make a subclass from something. However, I was under the impression that (object) and () worked the same way.
object
is for python2.x to use new classes, while python3.x automatically uses new classes. Python2.x is almost dead now anyways, so there is not much point anymore except for habit. Anything within these parenthesis is that class' super class. In the example of making a state machine...States is the super class and Menu and Game are the sub classes. All of States attributes are passes to each subclass. And anything that needs to remain between states can be in the super class as well. There is more detailed info on multiple parts class tutorials here.(Feb-18-2019, 09:14 PM)andrerocha1998 Wrote: What is considered spaghetti code by the way?Your remake is a little cleaner. It drove me nuts that you had 3 separate functions to handle movement in your first code.
Recommended Tutorials: