Top Banner
Intro. to Game Programming Want to program a game?
23

Intro. to Game Programming Want to program a game?

Dec 14, 2015

Download

Documents

Toby Reed
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intro. to Game Programming Want to program a game?

Intro. to Game Programming

Want to program a game?

Page 2: Intro. to Game Programming Want to program a game?

Very Important Points

• Classroom etiquette• Lab etiquette• Problems with – Teacher– Course content (Course Outline)– Evaluation– Programming for labs– Personal

Page 3: Intro. to Game Programming Want to program a game?

Basics

• Game Consoles and mobile devices• Hardware, Software and Firmware• 1’s and 0’s• Assembly Language• HLL (High Level Language)

Page 4: Intro. to Game Programming Want to program a game?

Game Consoles and Mobile

• All game machines share their internals with regular computer architecture

• All game machines have– Input– Output– Processing

Page 5: Intro. to Game Programming Want to program a game?

Hardware, Software & Firmware

• Hardware refers to a PHYSICAL DEVICE• Software refers to INFORMATION that

commands a device• Firmware refers to EMBEDDED Software –

fixed INSIDE a device

Page 6: Intro. to Game Programming Want to program a game?

Processing

• Game consoles have microprocessors that understand and perform operations based on a PATTERN of 1’s and 0’s

Page 7: Intro. to Game Programming Want to program a game?

1’s and 0’s

• Can be COMMANDS (or INSTRUCTIONS) to a device

• Can be DATA for use by a device• Determination of interpretation depends on

the CONTEXT of the 1s and 0s

Page 8: Intro. to Game Programming Want to program a game?

Machine Code

• Jumping to the address 1024:[ op | target address ] 2 1024 decimal000010 00000 00000 00000 10000 000000

binary

Page 9: Intro. to Game Programming Want to program a game?

Assembly Code• MOV r0, #0C ;load base address of string into r0

LOAD: MOV r1,(r0) ;load contents into r1CALL PRINT ; call a print routine to print the character in r1INC r0 ;point to next characterJMP LOAD ;load next character

• ALMOST ENGLISH

Page 10: Intro. to Game Programming Want to program a game?

High Level Language

• Early HLL – Fortran – Cobol• Basic• Pascal• C (from B) Jumping to the address 1024:• C++• Java

Page 11: Intro. to Game Programming Want to program a game?

Why C++?

• Industry Standard• 70% of Game Developers use this language on

a DAILY basis• Object-oriented• Practical outside of game development in

industry

Page 12: Intro. to Game Programming Want to program a game?

How do we make a program?

• Compile• Link• Load

Page 13: Intro. to Game Programming Want to program a game?

COMPILE

• Command Line

cc -c file.c

• GUI (Graphical User Interface)

Go to menu option… Build and select Compile

Page 14: Intro. to Game Programming Want to program a game?

COMPILE (More)

• Compiling takes English-like language and creates instructions that the computer can follow.

• Calls to other code will be links and need to be resolved in order to build REAL executable 1’s and 0’s

Page 15: Intro. to Game Programming Want to program a game?

LINK and LOAD

• Command Line

ln file1.o file2.o

• GUI (Graphical User Interface)

Go to menu option… Build and select BUILD

Page 16: Intro. to Game Programming Want to program a game?

LINK and LOAD (More)

• All calls to other code are resolved into actual locations where the code is now residing.

• Programmers use libraries that contain many commonly requested functions. These are resolved in the LINK and LOAD process as well

• The LOAD process refers to the first part of executing (or running) the program on a computer.

Page 17: Intro. to Game Programming Want to program a game?

Hello World in C++#include <iostream>

using namespace std;

int main(){ cout << “Hello World" << endl; return 0;}

Page 18: Intro. to Game Programming Want to program a game?

Hello World in C++

#include <iostream>

• Preprocessor command – starts with ‘#’ • Processed BEFORE actual compile• Effect of including an entire file inside your file

Page 19: Intro. to Game Programming Want to program a game?

Hello World in C++

using namespace std;

• Declares where to assume you are “using” functions

• “std” means STANDARD and allows a command like “cout” to be understood

Page 20: Intro. to Game Programming Want to program a game?

Hello World in C++

int main(){}• A function called “main” which returns an “int”

value• “main” MUST be in all C++ programs• “{“ “}” delimit the function (indicate what is

inside the function)

Page 21: Intro. to Game Programming Want to program a game?

Hello World in C++

cout << “Hello World" << endl;• “cout” is an object that is connected to our

terminal screen by default• “Hello World” is sent to the object for display

on the screen• “endl” is a “manipulator” that adds a

CR LF (Carriage Return and Line Feed)

Page 22: Intro. to Game Programming Want to program a game?

Compiling Hello World in C++

• Save the contents of the program into a file called “hello.cpp”

• Run the following command

c++ -o hello hello.cpp

• The PROGRAM is created… linking and loading is ALSO performed (by default)

Page 23: Intro. to Game Programming Want to program a game?

Running the Hello World Program

• In a Unix/MacOS/Linux environment

./hello

• In Windows… the program MUST be named with “.exe” on the end

hello.exe