Computer Engineering (Programming Language: Swift)

15
Computer Engineering By Sethmi Kachchakaduge, Kevin Adams, Kimi Hirano

Transcript of Computer Engineering (Programming Language: Swift)

Page 1: Computer Engineering (Programming Language: Swift)

Computer Engineering By Sethmi Kachchakaduge, Kevin Adams, Kimi

Hirano

Page 2: Computer Engineering (Programming Language: Swift)

Overview● Intro● Project Description

o Building the platformo Example Codeo Flappy Fly Code

● Analysiso Challengeso What we learned

Page 3: Computer Engineering (Programming Language: Swift)

Intro to Computer Engineering● Combines fields of electrical engineering and

computer science to develop computer hardware and software

● More focus on digital systems● Programming

Page 4: Computer Engineering (Programming Language: Swift)

Project Description● Created “Flappy Fly”

o Version of Flappy Birdo Swift

● Programmed codeo Xcode

● SpriteBuildero Built in partso Location control

Page 5: Computer Engineering (Programming Language: Swift)

Building the platform● Spritebuilder

o Backgroundo Groundo Obstacleso Heroo Nodeso Physics

Page 6: Computer Engineering (Programming Language: Swift)
Page 7: Computer Engineering (Programming Language: Swift)

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

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

%=)● Variables● Logic

o if and elseo True and False

Page 8: Computer Engineering (Programming Language: Swift)

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

Page 9: Computer Engineering (Programming Language: Swift)

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

Page 10: Computer Engineering (Programming Language: Swift)

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

Page 11: Computer Engineering (Programming Language: Swift)
Page 12: Computer Engineering (Programming Language: Swift)

Final Game

Page 13: Computer Engineering (Programming Language: Swift)

Challenges● Inserting code in proper location

● Understanding the code

● Correctly following building process

Page 14: Computer Engineering (Programming Language: Swift)

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

Page 15: Computer Engineering (Programming Language: Swift)

Thank You