LoginSignup
0
0

More than 1 year has passed since last update.

Playgroundsはplaygroundとは異なります

Posted at

Playgroundsの「コードを学ぼう2」でswiftの勉強中!
今、ようやく、「宝石があちこちにランダムに」をクリアしたところ。
継続は力なりと信じて、継続しています…。

test.swift
let totalGems = randomNumberOfGems

var m_gem = 0
var flg = true

while !(m_gem == totalGems) {
    if !isBlocked && !isBlockedLeft {
        moveForward()
    }else if !isBlocked {
        moveForward()
        if isOnGem {
            collectGem()
            m_gem += 1
        }
    }else{
        turnLeft()
        turnLeft()
        if flg {
            pinkPortal.isActive = false
            bluePortal.isActive = true
            flg = false
        }else {
            pinkPortal.isActive = true
            bluePortal.isActive = false
            flg = true
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0