"Aurora / Relay. Original LearnSqueak endless runner; native Squeak 6.1. File in, then Do It: ARApp open." Object subclass: #ARVector instanceVariableNames: 'x y z' classVariableNames: '' poolDictionaries: '' category: 'LearnSqueak-AuroraRelay'! Object subclass: #ARRun instanceVariableNames: 'player objects generator state distance coins ticks seed' classVariableNames: '' poolDictionaries: '' category: 'LearnSqueak-AuroraRelay'! Morph subclass: #ARView instanceVariableNames: 'app camera' classVariableNames: '' poolDictionaries: '' category: 'LearnSqueak-AuroraRelay'! Morph subclass: #ARApp instanceVariableNames: 'game view window info status controller' classVariableNames: '' poolDictionaries: '' category: 'LearnSqueak-AuroraRelay'! SystemWindow subclass: #ARWindow instanceVariableNames: 'fixedExtent' classVariableNames: '' poolDictionaries: '' category: 'LearnSqueak-AuroraRelay'! !ARVector class methodsFor: 'tutorial'! x: a y: b z: c ^ self new setX: a y: b z: c ! ! !ARVector methodsFor: 'tutorial'! setX: a y: b z: c x := a. y := b. z := c. ^ self ! ! !ARVector methodsFor: 'tutorial'! x ^ x ! ! !ARVector methodsFor: 'tutorial'! y ^ y ! ! !ARVector methodsFor: 'tutorial'! z ^ z ! ! !ARVector methodsFor: 'tutorial'! + other ^ self class x: x + other x y: y + other y z: z + other z ! ! !ARVector methodsFor: 'tutorial'! - other ^ self class x: x - other x y: y - other y z: z - other z ! ! !ARVector methodsFor: 'tutorial'! * number ^ self class x: x * number y: y * number z: z * number ! ! !ARVector methodsFor: 'tutorial'! asArray ^ {x. y. z} ! ! !ARRun methodsFor: 'tutorial'! initialize super initialize. seed := 314159. self restart ! ! !ARRun methodsFor: 'tutorial'! restart state := #ready. distance := 0.0. coins := 0. ticks := 0. objects := OrderedCollection new. player := ARVector x: 0 y: 0 z: 0 ! ! !ARRun methodsFor: 'tutorial'! player ^ player ! ! !ARRun methodsFor: 'tutorial'! objects ^ objects ! ! !ARRun methodsFor: 'tutorial'! generator ^ generator ! ! !ARRun methodsFor: 'tutorial'! state ^ state ! ! !ARRun methodsFor: 'tutorial'! distance ^ distance ! ! !ARRun methodsFor: 'tutorial'! coins ^ coins ! ! !ARRun methodsFor: 'tutorial'! ticks ^ ticks ! ! !ARRun methodsFor: 'tutorial'! seed ^ seed ! ! !ARRun methodsFor: 'tutorial'! seed: number seed := number. self restart ! ! !ARRun methodsFor: 'tutorial'! score ^ distance floor + (coins * self coinValue) ! ! !ARRun methodsFor: 'tutorial'! coinValue ^ 25 ! ! !ARRun methodsFor: 'tutorial'! isRunning ^ state = #running ! ! !ARRun methodsFor: 'tutorial'! tick ^ self ! ! !ARRun methodsFor: 'tutorial'! stepOnce self tick ! ! !ARRun methodsFor: 'tutorial'! statusText ^ 'A three-number value object represents a position before we draw perspective.' ! ! !ARApp class methodsFor: 'tutorial'! open ^ self new open ! ! !ARApp methodsFor: 'tutorial'! initialize super initialize. self extent: 968@678; color: (Color fromString: '#111B2B'). game := ARRun new. view := ARView new app: self; position: self position + (20@103). self addMorph: view. self label: 'AURORA / RELAY' at: 22@12 size: 27 color: '#F2F5FF'. self label: 'Run the skyway. Read the objects. Build the whole game.' at: 23@50 size: 14 color: '#B8C5DA'. self label: ('CHECKPOINT ', self stage printString, ' / 10') at: 740@20 size: 14 color: '#73E5D2'. self label: self stageTitle at: 23@78 size: 14 color: '#F8C976'. info := self label: '' at: 22@624 size: 15 color: '#EFF6FE'. status := self label: '' at: 22@655 size: 12 color: '#ACBDD5'. self buildSidebar. self refresh ! ! !ARApp methodsFor: 'tutorial'! label: string at: point size: size color: hex | label | label := StringMorph contents: string font: (TextStyle default fontOfSize: size). label position: self position + point; color: (Color fromString: hex). self addMorph: label. ^ label ! ! !ARApp methodsFor: 'tutorial'! button: string at: point action: selector | button | button := SimpleButtonMorph new label: string; target: self; actionSelector: selector; color: (Color fromString: '#D4E6ED'); yourself. button position: self position + point. self addMorph: button ! ! !ARApp methodsFor: 'tutorial'! buildSidebar self label: 'THREE LANES' at: 747@111 size: 16 color: '#73E5D2'. self label: 'A / D or Left / Right' at: 747@145 size: 12 color: '#DCE6F5'. self label: 'Tap to change lanes' at: 747@167 size: 12 color: '#9DB1CF'. self label: 'W / Up / Space: jump' at: 747@199 size: 12 color: '#DCE6F5'. self label: 'S / Down: slide' at: 747@227 size: 12 color: '#DCE6F5'. self label: 'READ THE ROAD' at: 747@278 size: 16 color: '#F8C976'. self label: 'Coral wall: change lane' at: 747@312 size: 12 color: '#EAA4AB'. self label: 'Orange hurdle: jump' at: 747@340 size: 12 color: '#F4C18A'. self label: 'Violet arch: slide' at: 747@368 size: 12 color: '#C6ADF8'. self label: 'Gold sparks: +25 points' at: 747@396 size: 12 color: '#F8D789'. self stage >= 4 ifTrue: [self button: 'Tick once' at: 747@446 action: #tickOnce]. self stage >= 8 ifTrue: [self button: 'Start / Pause' at: 747@483 action: #togglePause. self button: 'Restart' at: 855@483 action: #restart]. self label: 'Enter: start / pause' at: 747@539 size: 12 color: '#9DB1CF'. self label: 'Esc: pause R: restart' at: 747@565 size: 12 color: '#9DB1CF'. self label: 'Click scene for focus' at: 747@591 size: 11 color: '#73E5D2' ! ! !ARApp methodsFor: 'tutorial'! game ^ game ! ! !ARApp methodsFor: 'tutorial'! view ^ view ! ! !ARApp methodsFor: 'tutorial'! window ^ window ! ! !ARApp methodsFor: 'tutorial'! refresh info contents: ('SCORE ', game score printString, ' SPARKS ', game coins printString, ' METERS ', game distance floor printString, ' ', game state asString asUppercase). status contents: game statusText. view changed ! ! !ARApp methodsFor: 'tutorial'! open window ifNotNil: [window comeToFront. ^ self]. window := ARWindow new model: self; setLabel: 'Aurora / Relay - native Squeak endless runner'. window addMorph: self fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1)). window fixedExtent: 978@711. window openInWorld. window position: World position + (10@10). ^ self ! ! !ARApp methodsFor: 'tutorial'! okToClose ^ true ! ! !ARApp methodsFor: 'tutorial'! release ^ self ! ! !ARApp methodsFor: 'tutorial'! windowIsClosing self stopStepping. window := nil ! ! !ARApp methodsFor: 'tutorial'! wantsStepsIn: aWindow ^ false ! ! !ARApp methodsFor: 'tutorial'! synchronizeStepping self stopStepping ! ! !ARWindow methodsFor: 'tutorial'! fixedExtent: point fixedExtent := point. super extent: point ! ! !ARWindow methodsFor: 'tutorial'! extent: point super extent: (fixedExtent ifNil: [point]) ! ! !ARWindow methodsFor: 'tutorial'! lookFocused super lookFocused. label ifNotNil: [label color: Color white] ! ! !ARWindow methodsFor: 'tutorial'! lookUnfocused super lookUnfocused. label ifNotNil: [label color: (Color gray: 0.8)] ! ! !ARView methodsFor: 'tutorial'! app: anApp app := anApp. self extent: 706@500 ! ! !ARView methodsFor: 'tutorial'! text: string at: point size: size on: canvas color: hex canvas drawString: string at: self position + point font: (TextStyle default fontOfSize: size) color: (Color fromString: hex) ! ! !ARView methodsFor: 'tutorial'! drawOn: canvas | center | canvas fillRectangle: self bounds color: (Color fromString: '#0D1427'). center := self position + (353@250). -6 to: 6 do: [:x | canvas line: center + ((x*40) @ -155) to: center + ((x*40)@155) width: 1 color: (Color fromString: '#243952')]. -4 to: 4 do: [:y | canvas line: center + (-240@(y*40)) to: center + (240@(y*40)) width: 1 color: (Color fromString: '#243952')]. canvas line: center - (275@0) to: center + (275@0) width: 2 color: (Color fromString: '#73E5D2'). canvas line: center - (0@185) to: center + (0@185) width: 2 color: (Color fromString: '#73E5D2'). canvas fillOval: (center - (8@8) extent: 16@16) color: (Color fromString: '#F8C976'). self text: 'START WITH A POSITION / x, y, z' at: 24@26 size: 16 on: canvas color: '#E9F3FF'. self text: 'Three lanes: x = -2.5, 0, +2.5' at: 204@439 size: 15 on: canvas color: '#F8C976' ! ! !ARApp methodsFor: 'tutorial'! stage ^ 1 ! ! !ARApp methodsFor: 'tutorial'! stageTitle ^ 'Coordinates before pixels' ! !