From e69d8eda4f6195821e0730f9b7ff8c4be127650d Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Thu, 28 May 2020 13:04:24 -0600 Subject: [PATCH] adjusted game visuals and hit-tested the tap gesture against the bucket area --- .../panelback.imageset/Contents.json | 22 ++++++ .../panelback.imageset/panelback.png | Bin 0 -> 2138 bytes .../panelback.imageset/panelback@2x.png | Bin 0 -> 2539 bytes Privyet/Base.lproj/Main.storyboard | 63 +++++++++--------- Privyet/GameScene.swift | 10 ++- Privyet/GameViewController.swift | 9 ++- Privyet/Privyet.swift | 2 +- 7 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 Privyet/Assets.xcassets/panelback.imageset/Contents.json create mode 100644 Privyet/Assets.xcassets/panelback.imageset/panelback.png create mode 100644 Privyet/Assets.xcassets/panelback.imageset/panelback@2x.png diff --git a/Privyet/Assets.xcassets/panelback.imageset/Contents.json b/Privyet/Assets.xcassets/panelback.imageset/Contents.json new file mode 100644 index 0000000..7ed96a4 --- /dev/null +++ b/Privyet/Assets.xcassets/panelback.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "filename" : "panelback.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "panelback@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Privyet/Assets.xcassets/panelback.imageset/panelback.png b/Privyet/Assets.xcassets/panelback.imageset/panelback.png new file mode 100644 index 0000000000000000000000000000000000000000..420f85c8a8fbeb5bda396b7438102596a6ea2424 GIT binary patch literal 2138 zcmYk7c{CIZ7siLdSbOb^F-App%GMaAu?#czW$a6uF(f;~3>ld+dM#y5_RwM?TecJ? zWW=#$DMTteubnKZK7HSL&)2!<-h0mPJkMXxIrk=5Tbl53OK<}K06q-b$o6<+kK2or z<9Lb-i1`BmY;#dqC!*~Yl5}urkhiZtL7EsDOpqp!eZ2ty^2Dm6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ATH>0ZTs^U2nNQ1GCGckzfPhF08y-zNGCJGPCs_dfmN^@Ul@ z_7U9p@CHltUj^d-TtYqo09bDM8X8(-3=RK1c*kchpOSVF-C-?Ev$9J%B?40V8{tK_ z6g5Ig)^nri{MTp>P;-w%kcC9Lu$W0({pZgExY4#wXGf5uKK~I*NGQ>km?pSx#;t;j z4vvH^w1mA_*F)0p=Xi%F19JoOo*KFJdO3FXJI0-ji}6seP1eDfwv#ARr(f^A5+B%N z>@6(Ygoy%KPi-n|nCFpik)wvS;p;*sPBsn+0|{N`*HZV>Rua2{@_AHwE@H`jiP0}f|1=E-bX+g_{u*7W0gsSX3?{U)@;7yj}%4gd$v%)|)r z>vt8klx7?gu3)rt7y!T{^t)LAx%uM95JbdSpg^R&HT>EGs)V7D;6lIfm@Q^42Wu z|AUJE*Zdd$srlFVTl1&!w}$->BR%#fY!MRAJXBUoA?ZryE`1}eH!tr-Rh=Ke`(ff! zd9fD{-%qLO7WB{b>`WcbZLVR`Nvf1RO2iAw@Tcr?-+C8ERC;7%Z4=mKj&!GyHr%&^ zJrjxEYAZ=wD`#}z)7ND>Fp8=_D8?9%bYe#IPe9%y1Qsm6_Te}M00w1gRB7OO^FQK0 B%VYom literal 0 HcmV?d00001 diff --git a/Privyet/Assets.xcassets/panelback.imageset/panelback@2x.png b/Privyet/Assets.xcassets/panelback.imageset/panelback@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..67bc4a4ba85fc51442d447878c47dbf1ff07e79c GIT binary patch literal 2539 zcma)72T+sQ7XC4Gqz6H|5QUYZh%|u^LJgfz6@n5aEM*DRP$C%0u7oHMDGLM=U=@Ob zB28KV=?aK~AQ6NW6h$ElDunvtzFB78yf-^z@R z5w?~{4pwq(fS;G+@f}qw0KnZA@9rIq^v5ZOM`AHSp#jR#ap3{V0kJ_C0ElHSd-*g% zGz52WU>yGem6P(+kZ%X$H*j)?;}p-XyT(*)u~HA0re7Vf?ycY5q89IVb|a0X^zONa z^tqLB8=N*VD|yJsd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Dx)?RUw6A=ivJsSl8LXtm>3n-+>aDsf%2uCZv1s*vm zCEk--m?Z!J9YI){yK^=Vb2!5>0_gj)STblk3=SyOwDddXc`Tsc`jlQlb#9Ja!Kw7? z!*`cY3)vMS^T;{*WTft1r=|ab)*Rf`?0U(pX~na! zraJHPd(EZ@-9Z@nI>M7TZz7bOj|e-~JX)fd)G<1br(I`YaO5?F6NDbxcZyA3h)sy! zX2NO3hAhZbppxLI-GdHO)7=Zu(G0||%W(78kSXRsW4STe#Nl~>q+ry;CHZSTh;$K8 zgvd(*e7S}k`T&%6?)=dYji9uu?ODWBS|LD4hKZ~5gSm+?a~cN(4_MKZT{yr)P;n7c z=fJ;t4*XyIk23$1zt8`W`5*QFoBweQe(>M=|G@9J@t6L7{r&uXe!tDX^#6h1e}=#G z_w%>a2#rIq(nOD&^ZkCW2=HNdv%rrDmuZ%nSW3yKs*f#&yAPLK$iE`g2lMp4^;(lr zl9H0c?fo^11_C_n>8%weEEkfJlHye|3r(0k21c)p!&rkYH9j8X@tBz<7E7u4A$|i% zZoJ}cZ8oAXWn!YQ|6Q|qYXp^XPefR_TJG>+qx)s8ffty2$DN*!iAI0lKzaAwVtw{0JsQA~J%PdpY!Uhvu#N0&=}U_#ozjHugVYu0$! drEAS|qNtn6Xxou^0_Xn#2rDPc8u*3ee*wEiaEkx{ literal 0 HcmV?d00001 diff --git a/Privyet/Base.lproj/Main.storyboard b/Privyet/Base.lproj/Main.storyboard index 0924d44..966bd70 100644 --- a/Privyet/Base.lproj/Main.storyboard +++ b/Privyet/Base.lproj/Main.storyboard @@ -15,50 +15,47 @@ - - - - - - - - - - - - + - + - + + + @@ -99,10 +96,10 @@ - + - + diff --git a/Privyet/GameScene.swift b/Privyet/GameScene.swift index e176466..87d5ffc 100644 --- a/Privyet/GameScene.swift +++ b/Privyet/GameScene.swift @@ -22,6 +22,8 @@ class GameScene: SKScene { var tickLengthMillis = TickLengthLevelOne var lastTick: NSDate? + var scaleFactor: CGFloat! + var textureCache = Dictionary() var textureAtlas: SKTextureAtlas? @@ -41,7 +43,7 @@ class GameScene: SKScene { //print("Background is sized \(background.size)") // Scale computations - let scaleFactor = min(size.width / background.size.width, size.height / background.size.height) + scaleFactor = CGFloat(min(size.width / background.size.width, size.height / background.size.height)) background.position = CGPoint(x: 0, y: 0) background.anchorPoint = CGPoint(x: 0, y: 1.0) @@ -98,6 +100,12 @@ class GameScene: SKScene { return CGPoint(x: x, y: y) } + func rectForBucket() -> CGRect { + let width = CGFloat(NumColumns) * BlockSize + let height = CGFloat(NumRows) * BlockSize + return CGRect(x: (LayerPosition.x + (BlockSize / 2)) * scaleFactor, y: (LayerPosition.y + (BlockSize / 2)) * scaleFactor, width: width * scaleFactor, height: height * scaleFactor) + } + // Add the "preview" shape to the current scene. This also "rezzes in" a shape's block sprites. func addPreviewShapeToScene(shape: Shape, completion: @escaping () -> ()) { for block in shape.blocks { diff --git a/Privyet/GameViewController.swift b/Privyet/GameViewController.swift index c7f81c4..8c9a0d8 100644 --- a/Privyet/GameViewController.swift +++ b/Privyet/GameViewController.swift @@ -13,6 +13,7 @@ import GameplayKit class GameViewController: UIViewController, PrivyetDelegate, UIGestureRecognizerDelegate { var scene: GameScene! var privyet: Privyet! + var bucketRect: CGRect! var panPointReference: CGPoint? @IBOutlet weak var scoreLabel: UILabel! @@ -29,6 +30,9 @@ class GameViewController: UIViewController, PrivyetDelegate, UIGestureRecognizer scene = GameScene(size: skView.bounds.size) scene.scaleMode = .aspectFill + bucketRect = scene.rectForBucket() + print("Computed bucket rectangle = \(bucketRect!)") + scene.tick = didTick privyet = Privyet() @@ -45,7 +49,10 @@ class GameViewController: UIViewController, PrivyetDelegate, UIGestureRecognizer // Called when the user taps the screen @IBAction func didTap(_ sender: UITapGestureRecognizer) { - privyet.rotateShape() + let tapLoc = sender.location(in: view) + if bucketRect.contains(tapLoc) { + privyet.rotateShape() + } } // Called when the user slides their finger across the screen diff --git a/Privyet/Privyet.swift b/Privyet/Privyet.swift index b077920..216835a 100644 --- a/Privyet/Privyet.swift +++ b/Privyet/Privyet.swift @@ -15,7 +15,7 @@ let StartingColumn = 4 let StartingRow = 0 let PreviewColumn = 12 -let PreviewRow = 1 +let PreviewRow = 3 let PointsPerLine = 10 let LevelThreshold = 500