Created
April 4, 2019 12:07
-
-
Save taoufix/f70d7cc5850bf7ac341cf7dfc71df458 to your computer and use it in GitHub Desktop.
Untrusted level 07 - solutions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player = map.getPlayer(); | |
var c = ['#f00', '#0f0', '#ff0']; | |
player.setColor(c[Math.floor((Math.random() * 3) )]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player = map.getPlayer(); | |
var c = ['#f00', '#0f0', '#ff0']; | |
if (player.i == undefined) { player.i = 0; } | |
player.i = (player.i + 1)%3; | |
player.setColor(c[player.i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player = map.getPlayer(); | |
switch(player.getColor()) { | |
case '#f00': player.setColor('#0f0'); break; | |
case '#0f0': player.setColor('#ff0'); break; | |
case '#ff0': player.setColor('#f00'); break; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player = map.getPlayer(); | |
if (player.atLocation(24, 12)) { player.setColor('#f00'); } | |
if (player.atLocation(27, 12)) { player.setColor('#ff0'); } | |
if (player.atLocation(30, 12)) { player.setColor('#0f0'); } | |
if (player.atLocation(33, 12)) { player.setColor('#f00'); } | |
if (player.atLocation(36, 12)) { player.setColor('#ff0'); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment