@@ -48,7 +48,7 @@ First, let's create the basic structure for our game. We'll start with a simple
4848Create a new file called ` flappy_basic.rb ` :
4949
5050``` ruby
51- require ' live'
51+ require " live"
5252
5353class FlappyBasicView < Live ::View
5454 WIDTH = 420
@@ -172,7 +172,7 @@ class Bird < BoundingBox
172172
173173 def initialize (x = 30 , y = HEIGHT / 2 , width: 34 , height: 24 , skin: nil )
174174 super (x, y, width, height)
175- @skin = skin || ' bird'
175+ @skin = skin || " bird"
176176 @velocity = 0.0
177177 @jumping = false
178178 @dying = false
@@ -253,7 +253,7 @@ class Bird < BoundingBox
253253
254254 builder.inline_tag(:div ,
255255 id: id,
256- class : ' particle jump' ,
256+ class : " particle jump" ,
257257 style: " left: #{ center[0 ] } px; bottom: #{ center[1 ] } px; --rotation-angle: #{ angle } deg;"
258258 )
259259 end
@@ -387,12 +387,12 @@ class Pipe
387387
388388 # Render lower pipe
389389 builder.inline_tag(:div ,
390- class : ' pipe' ,
390+ class : " pipe" ,
391391 style: " left: #{ @x } px; bottom: #{ self .bottom} px; width: #{ @width } px; height: #{ @height } px; #{ display } "
392392 )
393393 # Render upper pipe
394394 builder.inline_tag(:div ,
395- class : ' pipe' ,
395+ class : " pipe" ,
396396 style: " left: #{ @x } px; bottom: #{ self .top} px; width: #{ @width } px; height: #{ @height } px; #{ display } "
397397 )
398398 end
@@ -461,7 +461,7 @@ class Gemstone < BoundingBox
461461 end
462462
463463 builder.inline_tag(:div ,
464- class : ' gemstone' ,
464+ class : " gemstone" ,
465465 style: " left: #{ @x } px; bottom: #{ @y } px; width: #{ @width } px; height: #{ @height } px; opacity: #{ opacity } ;"
466466 )
467467
@@ -475,7 +475,7 @@ class Gemstone < BoundingBox
475475
476476 builder.inline_tag(:div ,
477477 id: id,
478- class : ' particle bonus' ,
478+ class : " particle bonus" ,
479479 style: " left: #{ center[0 ] } px; bottom: #{ center[1 ] } px; --rotation-angle: #{ angle } deg;"
480480 )
481481 end
@@ -540,7 +540,7 @@ Let's add a way for players to choose different bird skins:
540540
541541``` ruby
542542class SkinSelectionView < Live ::View
543- SKINS = [' bird' , ' gull' , ' kiwi' , ' owl' ]
543+ SKINS = [" bird" , " gull" , " kiwi" , " owl" ]
544544
545545 def handle (event )
546546 skin = event.dig(:detail , :skin ) or return
@@ -627,7 +627,7 @@ class FlappyView < Live::View
627627 @pipes = nil
628628 @bonus = nil
629629
630- @skin_selection = SkinSelectionView .mount(self , ' skin-selection' )
630+ @skin_selection = SkinSelectionView .mount(self , " skin-selection" )
631631
632632 # Game state
633633 @score = 0
@@ -784,7 +784,7 @@ def step(dt)
784784 play_music
785785 end
786786 end
787-
787+
788788 # Check for collision
789789 if pipe.intersect?(@bird )
790790 Console .info(self , " Player has died." )
@@ -943,7 +943,7 @@ Here's how all the pieces fit together in a complete game file:
943943# !/usr/bin/env lively
944944# frozen_string_literal: true
945945
946- require ' live'
946+ require " live"
947947
948948# [All the classes we've built: BoundingBox, Bird, Pipe, Gemstone, SkinSelectionView, FlappyView]
949949# Put them all together in a single file for easy execution
0 commit comments