computer engineering (programming language: swift)

Post on 09-Feb-2017

203 Views

Category:

Engineering

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Computer Engineering By Sethmi Kachchakaduge, Kevin Adams, Kimi

Hirano

Overview● Intro● Project Description

o Building the platformo Example Codeo Flappy Fly Code

● Analysiso Challengeso What we learned

Intro to Computer Engineering● Combines fields of electrical engineering and

computer science to develop computer hardware and software

● More focus on digital systems● Programming

Project Description● Created “Flappy Fly”

o Version of Flappy Birdo Swift

● Programmed codeo Xcode

● SpriteBuildero Built in partso Location control

Building the platform● Spritebuilder

o Backgroundo Groundo Obstacleso Heroo Nodeso Physics

Coding Basics● Basic Comparators (==, >, <, >=,

<=)● Basic Operators (=, +=, -=, *=, /=,

%=)● Variables● Logic

o if and elseo True and False

Example• Var flappyFly = 6• flappyFly > 7 ‘false’• flappyFly < 7 ‘true’• If (flappyFly>4){• ‘flappyFly+=1’ • }• Else {• “flappyFly does nothing”• }

Control Flow● For loops● For in loops● While loops● Do while loops

Flappy Fly Code● Variable Ex

o var_gameOver = false

● Function Ex○ func spawnNewObstacle() {

var prevObstaclePos = _firstObstaclePosition if _obstacles.count > 0 { prevObstaclePos = _obstacles.last!.position.x }

● For loop Exo for ground in _grounds {

// get the world position of the ground let groundWorldPosition = _physicsNode.convertToWorldSpace(ground.position // get the screen position of the ground let groundScreenPosition = self.convertToNodeSpace(groundWorldPosition) // if the left corner is one complete width off the screen, move it to the right

Final Game

Challenges● Inserting code in proper location

● Understanding the code

● Correctly following building process

What we learned?● Different syntax● Order matters● Patience● Simplified code

Thank You

top related