0% found this document useful (0 votes)
17 views13 pages

Chap 0 Introduction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views13 pages

Chap 0 Introduction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Introduction to

Game Programming
Vuong Ba Thinh
Department of CS –CSE Faculty - HCMUT

1
Outline
• Course Introduction
• Evolution of Video Game Programming
• Game Loop
• Python - Pygame

2
Course Introduction
• Assessment:
• 80%: Assignments (6-7)
• One 3D
• 20%: Final Exam (multiple choices + writing test - 75 minutes)
• Reference:
• [1] Sanjay Madhav, Game Programming Algorithms and Techniques -
A Platform Agnostic Approach, 2014.
• [2] AI Sweigart, Making Games with Python & Pygame, 2012.
• [3] Mat Buckland, Programming Game AI By Example, 2004.
• [4] Paul V Craven, Program Arcade Games With Python and Pygame,
2014.

3
Evolution of Video Game
Programming
• Atari Era (1977–1985)
• NES and SNES Era (1985–1995)
• Playstation / Playstation 2 Era (1995–2005)
• Xbox 360, PS3, and Wii Era (2005–2013)
• The Future

• AAA game???

4
Game Loop

while game is running


process inputs
update game world
generate outputs
loop

Examples: 2048, Caro, Chicken Invader

Exercise: Read “Time and Games” – chapter 1 [1]


5
Game Objects
• What is Game Object?
• Types of Game Objects
• Draw-only
• Update-only
• ?

6
Python Tutorial
• print
• Data Type
• If statement
• Loop statement
• For loop
• While loop
• Function
• List
• Class

7
Pygame Tutorial
Hello World
1. import pygame, sys
2. from pygame.locals import *
3.
4. pygame.init()
5. DISPLAYSURF = pygame.display.set_mode((400, 300))
6. pygame.display.set_caption('Hello World!')
7. while True: # main game loop
8. for event in pygame.event.get():
9. if event.type == QUIT:
10. pygame.quit()
11. sys.exit()
12. pygame.display.update() 8
Computer Coordinate Systems

9
Color (RGB)
# Define some colors
BLACK = ( 0, 0, 0)
WHITE = ( 255, 255, 255)
GREEN = ( 0, 255, 0)
RED = ( 255, 0, 0)

10
Drawing Introduction
pygame.draw.rect — draw a rectangle shape

pygame.draw.polygon — draw a shape with any number of sides

pygame.draw.circle — draw a circle around a point

pygame.draw.ellipse — draw a round shape inside a rectangle

pygame.draw.arc — draw a partial section of an ellipse


pygame.draw.line — draw a straight line segment

pygame.draw.lines — draw multiple contiguous line segments

pygame.draw.aaline — draw fine antialiased lines


11
pygame.draw.aalines — draw a connected sequence of antialiased lines
Animation
• Sprite

• Animation

12
Controllers and Graphics
• Keyboard
• Mouse
• Game Controller

13

You might also like