SlideShare a Scribd company logo
1 of 25
Download to read offline
TECNOLOGIAS EMERGENTES EM JOGOS

Engenharia em Desenvolvimento de Jogos Digitais - 2013/2014

February 14, 2014

Daniela da Cruz
dcruz@ipca.pt
C BASICS
C basics

C  COMMENTS
There are two ways to include commentary text in a C program.

→

Inline comments

// This is an inline comment
→

Block comments

/* This is a block comment.
It can span multiple lines. */

3
C basics

C  VARIABLES
Variables are containers that can store dierent values.

type name
the = operator.

To declare a variable, you use the
to assign a value to it you use

syntax, and

double odometer = 9200.8;
int odometerAsInteger = (int)odometer;

4
C basics

C  CONSTANTS

The const variable modier tells to the compiler that a variable is
never allowed to change.

double const pi = 3.14159;

5
C basics

C  ARITHMETIC
The familiar +, -, *, / symbols are used for basic arithmetic
operations, and the modulo operator (%) can be used to return the
remainder of an integer division.

printf(6
printf(6
printf(6
printf(6
printf(6

+
*
/
%

2
2
2
2
2

=
=
=
=
=

%d,
%d,
%d,
%d,
%d,

6
6
6
6

+
*
/

2);
2);
2);
2);
6 % 2);

// 8
// 4
// 12
// 3
// 0

6
C basics

C  ARITHMETIC (2)
C also has increment (++) and decrement () operators. These are
convenient operators for adding or subtracting 1 from a variable.

int i = 0;
printf(%d, i);
i++;
printf(%d, i);
i++;
printf(%d, i);

// 0
// 1
// 2

7
C basics

C  RELATIONAL/LOGICAL OPERATORS
The most common relational/logical operators are shown below.

Operator
a == b

Description
Equal to

!=b
b
a = b
a  b
a = b

Greater than or equal to

!a

Logical negation

a

a

Not equal to
Greater than
Less than
Less than or equal to

a  b

Logical and

||

Logical or

a

b

8
C basics

C  CONDITIONALS
C provides the standard if statement found in most programming
languages.

int modelYear = 1990;
if (modelYear  1967) {
printf(That car is an antique!!!);
} else if (modelYear = 1991) {
printf(That car is a classic!);
} else if (modelYear == 2014) {
printf(That's a brand new car!);
} else {
printf(There's nothing special about that car.);
}
9
C basics

C  CONDITIONALS (2)
C also includes a
integral types 

switch

statement, however it

only works with

not oating-point numbers, pointers, or

Objective-C objects.

switch (modelYear) {
case 1987:
printf(Your car is from 1987.); break;
case 1989:
case 1990:
printf(Your car is from 1989 or 1990.); break;
default:
printf(I have no idea when your car was made.);
break;
}
10
C basics

C  LOOPS
The

while

the related

for loops can be used for iterating over values,
break and continue keywords let you exit a loop
and

and

prematurely or skip an iteration, respectively.

int modelYear = 1990;
int i = 0;
while (i5) {
if (i == 3) {
printf(Aborting the while-loop);
break;
}
printf(Current year: %d, modelYear + i);
i++;
}
11
C basics

C  LOOPS (2)
int modelYear = 1990, i;
for (i=0; i5; i++) {
if (i == 3) {
printf(Skipping a for-loop iteration);
continue;
}
printf(Current year: %d, modelYear + i);
}

12
C basics

C  TYPEDEF
The

typedef

keyword lets you create new data types or redene

existing ones.

typedef unsigned char ColorComponent;
int main() {
ColorComponent red = 255;
return 0;
}

13
C basics

C  STRUCTS
A struct is like a simple, primitive C object. It lets you aggregate
several variables into a more complex data structure, but doesn't
provide any OOP features (e.g., methods).

typedef struct {
unsigned char red;
unsigned char green;
unsigned char blue;
} Color;
int main() {
Color carColor = {255, 160, 0};
printf(Your color is (R: %u, G: %u, B: %u),
carColor.red, carColor.green, carColor.blue);
return 0;
}
14
C basics

C  ENUMS
The

enum

keyword is used to create an enumerated type, which is a

collection of related constants.

typedef enum {
FORD,
HONDA,
NISSAN,
PORSCHE
} CarModel;
int main() {
CarModel myCar = NISSAN;
return 0;
}
15
C basics

C  ARRAYS
The higher-level
the

NSArray

and

NSMutableArray

classes provided by

Foundation Framework are much more convenient than C

arrays.

int years[4] = {1968, 1970, 1989, 1999};

16
C basics

C  POINTERS
A pointer is a direct reference to a memory address.

→

The reference operator () returns the memory address of a
normal variable. This is how we create pointers.

→

The dereference operator (*) returns the contents of a
pointer's memory address.

int year = 1967;
int *pointer;
pointer = year;
printf(%d, *pointer);
*pointer = 1990;
printf(%d, year);

17
C basics

C  FUNCTIONS
There are four components to a C function: its return value, name,
parameters, and associated code block.

18
C basics

C  FUNCTIONS
Functions need to be dened before they are used.
C lets you separate the

implementation.
→

declaration of a function from its

A function declaration tells the compiler what the function's
inputs and outputs look like.

→

The corresponding implementation attaches a code block to
the declared function.

Together, these form a complete function denition.

19
C basics

C  STATIC FUNCTIONS
The

static

keyword let us alter the availability of a function or

variable.
By default, all functions have a global scope.
This means that as soon as we dene a function in one le, it's
immediately available everywhere else.
The

static

specier let us limit the function's scope to the current

le, which is useful for creating private functions and avoiding
naming conicts.

20
C basics

C  STATIC FUNCTIONS (2)
File

functions.m:

// Static function declaration
static int getRandomInteger(int, int);
// Static function implementation
static int getRandomInteger(int minimum, int maximum) {
return ((maximum - minimum) + 1) + minimum;
}
You would not be able to access

main.m.

getRandomInteger()

from

Note that the static keyword should be used on both the function
declaration and implementation.
21
C basics

C  STATIC VARIABLES

Variables declared inside of a function are reset each time the
function is called.
However, when you use the

static

modier on a local variable, the

function remembers its value across invocations.

22
C basics

C  STATIC VARIABLES (2)
int countByTwo() {
static int currentCount = 0;
currentCount += 2;
return currentCount;
}
int main(int argc, const char * argv[]) {
printf(%d, countByTwo());
// 2
printf(%d, countByTwo());
// 4
printf(%d, countByTwo());
// 6
}

return 0;

23
C basics

C  STATIC VARIABLES (2)

This use of the static keyword

does not aect the scope of local

variables.
Local variables are still only accessible inside of the function itself.

24
C basics

C  SUMMARY
We reviewed:

→

Variables

→

Conditionals

→

Loops

→

Typedef

→

Struct's

→

Enum's

→

Arrays

→

Pointers

→

Functions

→

Static (functions and variables)

25

More Related Content

What's hot

Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]Abhishek Sinha
 
Advanced Programming C++
Advanced Programming C++Advanced Programming C++
Advanced Programming C++guestf0562b
 
Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_eShikshak
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ AdvancedVivek Das
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna universitysangeethajames07
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Vivek Singh
 
Lec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptLec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptRushdi Shams
 

What's hot (20)

C introduction by thooyavan
C introduction by  thooyavanC introduction by  thooyavan
C introduction by thooyavan
 
Assignment12
Assignment12Assignment12
Assignment12
 
Assignment6
Assignment6Assignment6
Assignment6
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
 
Savitch Ch 09
Savitch Ch 09Savitch Ch 09
Savitch Ch 09
 
Savitch ch 09
Savitch ch 09Savitch ch 09
Savitch ch 09
 
Advanced Programming C++
Advanced Programming C++Advanced Programming C++
Advanced Programming C++
 
C++ book
C++ bookC++ book
C++ book
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
C introduction by piyushkumar
C introduction by piyushkumarC introduction by piyushkumar
C introduction by piyushkumar
 
Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_Lecture 3 getting_started_with__c_
Lecture 3 getting_started_with__c_
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
C++ Advanced
C++ AdvancedC++ Advanced
C++ Advanced
 
C Programming
C ProgrammingC Programming
C Programming
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna university
 
Assignment8
Assignment8Assignment8
Assignment8
 
Le langage rust
Le langage rustLe langage rust
Le langage rust
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
Lec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptLec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory Concept
 

Similar to TECNOLOGIAS EMERGENTES EM JOGOS DIGITAIS

UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...RSathyaPriyaCSEKIOT
 
Report on c and c++
Report on c and c++Report on c and c++
Report on c and c++oggyrao
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++DSCIGDTUW
 
88 c programs 15184
88 c programs 1518488 c programs 15184
88 c programs 15184Sumit Saini
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiSowmya Jyothi
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212Mahmoud Samir Fayed
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184Mahmoud Samir Fayed
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfYashwanthCse
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 

Similar to TECNOLOGIAS EMERGENTES EM JOGOS DIGITAIS (20)

UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
Ppt of c vs c#
Ppt of c vs c#Ppt of c vs c#
Ppt of c vs c#
 
C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.comC Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
 
C programming
C programmingC programming
C programming
 
Report on c and c++
Report on c and c++Report on c and c++
Report on c and c++
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
88 c programs 15184
88 c programs 1518488 c programs 15184
88 c programs 15184
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
Overview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya JyothiOverview of C Mrs Sowmya Jyothi
Overview of C Mrs Sowmya Jyothi
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
C language tutorial
C language tutorialC language tutorial
C language tutorial
 
The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
C Programming
C ProgrammingC Programming
C Programming
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 

More from Daniela Da Cruz

Introduction to iOS and Objective-C
Introduction to iOS and Objective-CIntroduction to iOS and Objective-C
Introduction to iOS and Objective-CDaniela Da Cruz
 
Game Development with AndEngine
Game Development with AndEngineGame Development with AndEngine
Game Development with AndEngineDaniela Da Cruz
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsDaniela Da Cruz
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - IntentDaniela Da Cruz
 
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Daniela Da Cruz
 
Android Introduction - Lesson 1
Android Introduction - Lesson 1Android Introduction - Lesson 1
Android Introduction - Lesson 1Daniela Da Cruz
 

More from Daniela Da Cruz (9)

Introduction to iOS and Objective-C
Introduction to iOS and Objective-CIntroduction to iOS and Objective-C
Introduction to iOS and Objective-C
 
Games Concepts
Games ConceptsGames Concepts
Games Concepts
 
Game Development with AndEngine
Game Development with AndEngineGame Development with AndEngine
Game Development with AndEngine
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical Systems
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - Intent
 
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
 
Android Lesson 2
Android Lesson 2Android Lesson 2
Android Lesson 2
 
Android Introduction - Lesson 1
Android Introduction - Lesson 1Android Introduction - Lesson 1
Android Introduction - Lesson 1
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 

TECNOLOGIAS EMERGENTES EM JOGOS DIGITAIS

  • 1. TECNOLOGIAS EMERGENTES EM JOGOS Engenharia em Desenvolvimento de Jogos Digitais - 2013/2014 February 14, 2014 Daniela da Cruz dcruz@ipca.pt
  • 3. C basics C COMMENTS There are two ways to include commentary text in a C program. → Inline comments // This is an inline comment → Block comments /* This is a block comment. It can span multiple lines. */ 3
  • 4. C basics C VARIABLES Variables are containers that can store dierent values. type name the = operator. To declare a variable, you use the to assign a value to it you use syntax, and double odometer = 9200.8; int odometerAsInteger = (int)odometer; 4
  • 5. C basics C CONSTANTS The const variable modier tells to the compiler that a variable is never allowed to change. double const pi = 3.14159; 5
  • 6. C basics C ARITHMETIC The familiar +, -, *, / symbols are used for basic arithmetic operations, and the modulo operator (%) can be used to return the remainder of an integer division. printf(6 printf(6 printf(6 printf(6 printf(6 + * / % 2 2 2 2 2 = = = = = %d, %d, %d, %d, %d, 6 6 6 6 + * / 2); 2); 2); 2); 6 % 2); // 8 // 4 // 12 // 3 // 0 6
  • 7. C basics C ARITHMETIC (2) C also has increment (++) and decrement () operators. These are convenient operators for adding or subtracting 1 from a variable. int i = 0; printf(%d, i); i++; printf(%d, i); i++; printf(%d, i); // 0 // 1 // 2 7
  • 8. C basics C RELATIONAL/LOGICAL OPERATORS The most common relational/logical operators are shown below. Operator a == b Description Equal to !=b b a = b a b a = b Greater than or equal to !a Logical negation a a Not equal to Greater than Less than Less than or equal to a b Logical and || Logical or a b 8
  • 9. C basics C CONDITIONALS C provides the standard if statement found in most programming languages. int modelYear = 1990; if (modelYear 1967) { printf(That car is an antique!!!); } else if (modelYear = 1991) { printf(That car is a classic!); } else if (modelYear == 2014) { printf(That's a brand new car!); } else { printf(There's nothing special about that car.); } 9
  • 10. C basics C CONDITIONALS (2) C also includes a integral types switch statement, however it only works with not oating-point numbers, pointers, or Objective-C objects. switch (modelYear) { case 1987: printf(Your car is from 1987.); break; case 1989: case 1990: printf(Your car is from 1989 or 1990.); break; default: printf(I have no idea when your car was made.); break; } 10
  • 11. C basics C LOOPS The while the related for loops can be used for iterating over values, break and continue keywords let you exit a loop and and prematurely or skip an iteration, respectively. int modelYear = 1990; int i = 0; while (i5) { if (i == 3) { printf(Aborting the while-loop); break; } printf(Current year: %d, modelYear + i); i++; } 11
  • 12. C basics C LOOPS (2) int modelYear = 1990, i; for (i=0; i5; i++) { if (i == 3) { printf(Skipping a for-loop iteration); continue; } printf(Current year: %d, modelYear + i); } 12
  • 13. C basics C TYPEDEF The typedef keyword lets you create new data types or redene existing ones. typedef unsigned char ColorComponent; int main() { ColorComponent red = 255; return 0; } 13
  • 14. C basics C STRUCTS A struct is like a simple, primitive C object. It lets you aggregate several variables into a more complex data structure, but doesn't provide any OOP features (e.g., methods). typedef struct { unsigned char red; unsigned char green; unsigned char blue; } Color; int main() { Color carColor = {255, 160, 0}; printf(Your color is (R: %u, G: %u, B: %u), carColor.red, carColor.green, carColor.blue); return 0; } 14
  • 15. C basics C ENUMS The enum keyword is used to create an enumerated type, which is a collection of related constants. typedef enum { FORD, HONDA, NISSAN, PORSCHE } CarModel; int main() { CarModel myCar = NISSAN; return 0; } 15
  • 16. C basics C ARRAYS The higher-level the NSArray and NSMutableArray classes provided by Foundation Framework are much more convenient than C arrays. int years[4] = {1968, 1970, 1989, 1999}; 16
  • 17. C basics C POINTERS A pointer is a direct reference to a memory address. → The reference operator () returns the memory address of a normal variable. This is how we create pointers. → The dereference operator (*) returns the contents of a pointer's memory address. int year = 1967; int *pointer; pointer = year; printf(%d, *pointer); *pointer = 1990; printf(%d, year); 17
  • 18. C basics C FUNCTIONS There are four components to a C function: its return value, name, parameters, and associated code block. 18
  • 19. C basics C FUNCTIONS Functions need to be dened before they are used. C lets you separate the implementation. → declaration of a function from its A function declaration tells the compiler what the function's inputs and outputs look like. → The corresponding implementation attaches a code block to the declared function. Together, these form a complete function denition. 19
  • 20. C basics C STATIC FUNCTIONS The static keyword let us alter the availability of a function or variable. By default, all functions have a global scope. This means that as soon as we dene a function in one le, it's immediately available everywhere else. The static specier let us limit the function's scope to the current le, which is useful for creating private functions and avoiding naming conicts. 20
  • 21. C basics C STATIC FUNCTIONS (2) File functions.m: // Static function declaration static int getRandomInteger(int, int); // Static function implementation static int getRandomInteger(int minimum, int maximum) { return ((maximum - minimum) + 1) + minimum; } You would not be able to access main.m. getRandomInteger() from Note that the static keyword should be used on both the function declaration and implementation. 21
  • 22. C basics C STATIC VARIABLES Variables declared inside of a function are reset each time the function is called. However, when you use the static modier on a local variable, the function remembers its value across invocations. 22
  • 23. C basics C STATIC VARIABLES (2) int countByTwo() { static int currentCount = 0; currentCount += 2; return currentCount; } int main(int argc, const char * argv[]) { printf(%d, countByTwo()); // 2 printf(%d, countByTwo()); // 4 printf(%d, countByTwo()); // 6 } return 0; 23
  • 24. C basics C STATIC VARIABLES (2) This use of the static keyword does not aect the scope of local variables. Local variables are still only accessible inside of the function itself. 24
  • 25. C basics C SUMMARY We reviewed: → Variables → Conditionals → Loops → Typedef → Struct's → Enum's → Arrays → Pointers → Functions → Static (functions and variables) 25