GAMEBOX
CS 1111 NOVEMBER 2019
GAMEBOX CS 1111 NOVEMBER 2019 GAMEBOX - - PowerPoint PPT Presentation
GAMEBOX CS 1111 NOVEMBER 2019 GAMEBOX https://cs1110.cs.virginia.edu/gamebox-summary.html Save gamebox.py into every folder that uses gamebox Gamebox is a simple game library built on top of Pygame It supports Animation
CS 1111 NOVEMBER 2019
GAMEBOX
IMPORT STATEMENTS
import pygame import gamebox camera = gamebox.Camera(800, 600) # you can change these # dimensions to change the window size
CLICKING_EXAMPLE.PY
TIME LOOP
gamebox.timer_loop(30, tick)
def tick(keys):
TIME LOOP
if pygame.K_UP in keys:
if camera.mouseclick:
camera.draw(logo)
camera.display()
CAMERA
Point of Origin (0,0) Y increases X increases
GAMEBOXES
GAMEBOXES MOVEMENT
b1 = gamebox.from_color(50, 100, "red", 20, 40) # x, y, color, width, height b1.move(5, 6) b1.x -= 5 b1.center(50, 100)
EXAMPLES – SIMPLE ANIMATION
https://cs1110.cs.virginia.edu/files/cs1111_19fa/starfield.py
https://cs1110.cs.virginia.edu/files/cs1111_19fa/animation.py
https://cs1110.cs.virginia.edu/files/cs1111_19fa/pygame_demo.py
COLLISION DETECTION
print(b1.touches(b2))
print(b1.bottom_touches(b2))
b1.move_to_stop_overlapping(b2) b1.move_both_to_stop_overlapping(b2)
EXAMPLES
https://cs1110.cs.virginia.edu/files/cs1111_19fa/arrow_keys.py
https://cs1110.cs.virginia.edu/files/cs1111_19fa/infinite_jumper.py
https://cs1110.cs.virginia.edu/files/cs1111_19fa/health_bar.py
https://cs1110.cs.virginia.edu/files/cs1111_19fa/basic_carry_stuff.py