-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed unary negation bug, removed newline from print
- Loading branch information
1 parent
53012db
commit aeb008c
Showing
11 changed files
with
96 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//constants | ||
var WIDTH: int const = 10; | ||
var HEIGHT: int const = 10; | ||
|
||
//WIDTH * HEIGHT in size | ||
var tiles: [[int]] const = [ | ||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], | ||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1] | ||
]; | ||
|
||
var tileset: [int: string] const = [ | ||
0: " ", | ||
1: " X " | ||
]; | ||
|
||
//variables | ||
var posX: int = 5; | ||
var posY: int = 5; | ||
|
||
//functions | ||
fn draw() { | ||
for (var j: int = 0; j < HEIGHT; j++) { | ||
for (var i: int = 0; i < WIDTH; i++) { | ||
//draw the player pos | ||
if (i == posX && j == posY) { | ||
print " O "; | ||
continue; | ||
} | ||
|
||
print tileset[ tiles[i][j] ]; | ||
} | ||
print "\n"; | ||
} | ||
print "\n"; | ||
} | ||
|
||
fn move(xrel: int, yrel: int) { | ||
if (xrel > 1 || xrel < -1 || yrel > 1 || yrel < -1 || (xrel != 0 && yrel != 0)) { | ||
print "too fast!\n"; | ||
return; | ||
} | ||
|
||
if (tiles[posX + xrel][posY + yrel] > 0) { | ||
print "Can't move that way\n"; | ||
return; | ||
} | ||
|
||
posX += xrel; | ||
posY += yrel; | ||
|
||
draw(); | ||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import compound; | ||
|
||
var a = [false, false, false]; | ||
var d = ["one": false, "two": false]; | ||
|
||
print d.containsKey("one"); | ||
print d.containsKey("three"); | ||
var xrel: int = 0; | ||
var yrel: int = 0; | ||
|
||
if (xrel > 1 || xrel < -1 || yrel > 1 || yrel < -1) { | ||
print "outside"; | ||
} | ||
else { | ||
print "inside"; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//This is just a check to ensure that unary minus doesn't screw up the AST | ||
|
||
var xrel: int = 0; | ||
var yrel: int = 0; | ||
|
||
assert (xrel > 1 || xrel < -1 || yrel > 1 || yrel < -1) == false, "or-chaining bugfix failed"; | ||
|
This file contains 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
This file contains 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