-
Web Dev Bootcamp TIL Day-7(Game Project Cont.)TIL 2022. 4. 26. 21:06
We must keep in mind that we are working in a coordinate system when inputting positions for stages and characters
- Top left corner of the screen is (x, y) = (0, 0)
- Bottom right corner of the screen is (x, y) = (screen width, screen height)
- ex) the (x, y) coordinates for the center of a ball will be: (self.rect.x + self.ball_rad, self.rect.y + self.ball_rad)
Set binary indicators to show the state of the game
- ex) for game is not over ----- > game_over = 0
- ex) for wall is destroyed ------> wall_destroyed = 1
Use print statement to test functions between the addition of new class / features
Checking for collision
- check if the absolute value between the coordinates of two objects is below a certain threshold
- can combine w/ another condition such as the ball is moving downwards
#if collision occurs from bottom of ball/top of block and ball is moving downwards if abs(self.rect.bottom - item[0].top) < collision_thresh and self.speed_y > 0: self.speed_y *= -1
Using Temp Variable to swap values
a = 11 b = 7 temp = a a = b b = temp
'TIL' 카테고리의 다른 글
Web Dev Bootcamp TIL Day-9(Djangogram Start) (2) 2022.04.28 Web Dev Bootcamp TIL Day-8(Python Basics/ Flask Review/ Git Crash Course) (0) 2022.04.27 Web Dev Bootcamp TIL Day-6(Game Project Start) (0) 2022.04.26 Web Dev Bootcamp TIL Day-5(Git and Conda) (0) 2022.04.25 Team Intro Project KPT (0) 2022.04.22