gamelogic
DESCRIPTION
TRANSCRIPT
![Page 1: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/1.jpg)
![Page 2: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/2.jpg)
![Page 3: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/3.jpg)
![Page 4: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/4.jpg)
How can make this?
![Page 5: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/5.jpg)
Programming Language!
![Page 6: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/6.jpg)
Code
• printf(“Hello World”);
![Page 7: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/7.jpg)
Code
• DrawImage( img, x, y );
![Page 8: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/8.jpg)
![Page 9: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/9.jpg)
Important Logic
• Game loop• Change screen• Collision detection• Status check
![Page 10: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/10.jpg)
What is computer?
• Fast calculator
![Page 11: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/11.jpg)
Game loop
![Page 12: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/12.jpg)
Game loop
• It’s all of the game loop logic
![Page 13: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/13.jpg)
Game loop
![Page 14: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/14.jpg)
![Page 15: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/15.jpg)
Game loop
![Page 16: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/16.jpg)
Game loop
![Page 17: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/17.jpg)
Game loop
![Page 18: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/18.jpg)
Change screen
![Page 19: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/19.jpg)
Change screen
• Simple code
![Page 20: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/20.jpg)
Change screen
![Page 21: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/21.jpg)
Change screen
![Page 22: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/22.jpg)
Change screen
![Page 23: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/23.jpg)
Change screen
![Page 24: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/24.jpg)
Change screen
![Page 25: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/25.jpg)
Change screen
• How can change screen?
![Page 26: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/26.jpg)
Notice!
• Do not write code like this.• This code is not stable.• Just for showing example.
![Page 27: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/27.jpg)
Collision detection
![Page 28: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/28.jpg)
Collision detection
• Why check collision?
![Page 29: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/29.jpg)
Collision detection
• Computer don’t know anything• Just have data
![Page 30: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/30.jpg)
Collision detection
• Remember mathematics!
![Page 31: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/31.jpg)
Collision detection
• Circle collision detection
![Page 32: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/32.jpg)
Collision detection
• Rectangle collision detection
![Page 33: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/33.jpg)
Collision detection
• Rectangle collision detection
boolean rectangle_collision(float x_1, float y_1, float width_1, float height_1, float x_2, float y_2, float width_2, float height_2)
{return !(x_1 > x_2+width_2 || x_1+width_1 < x_2 ||
y_1 > y_2+height_2 || y_1+height_1 < y_2);}
![Page 34: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/34.jpg)
Collision detection
• How about button?
![Page 35: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/35.jpg)
Collision detection
• But how about it?
![Page 36: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/36.jpg)
Collision detection
• But how about it?
![Page 37: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/37.jpg)
Status check
![Page 38: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/38.jpg)
Status check
• Player is dead?
![Page 39: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/39.jpg)
Status check
• I want to buy weapon!
![Page 40: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/40.jpg)
Status check
• Do I have money?
![Page 41: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/41.jpg)
Status check
• Drinking potion!
![Page 42: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/42.jpg)
Status check
• Drinking potion!
![Page 43: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/43.jpg)
What do you think about it?
![Page 44: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/44.jpg)
Q n A
![Page 45: Gamelogic](https://reader033.vdocument.in/reader033/viewer/2022061118/546968e3af795946718b4fc4/html5/thumbnails/45.jpg)