ec2-18-223-171-12.us-east-2.compute.amazonaws.com | ToothyWiki | Kazuhiko | RecentChanges | Login | Webcomic
- [Click to play]
Simple control-based movement game script.
Based largely on MoonShadow/Sokoban
[Recompile] [View compiler errors]
logic
{
// ~~~~~~~ Initial map layout
// 0 = floor
// 1 = wall
// 2 = player
array map
{
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 2, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 1, 0, 0, 1,
1, 0, 0, 0, 0, 1, 0, 0, 1,
1, 0, 0, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1
}
int mapwidth { 9 }
int mapheight { 9 }
// Denote the current location of the player
// This should be set automatically, but I don't want to deal with an
// initialisation step at this point
int location { 15 }
// Allow the four movement actions when it is safe to move that way
when { (map[location-1] == 0) }
allow
{
map[location-1] = map[location];
map[location] = 0;
location = location - 1;
}
label { "key_a" }
when { (map[location+1] == 0) }
allow
{
map[location+1] = map[location];
map[location] = 0;
location = location + 1;
}
label { "key_d" }
when { (map[location+mapwidth] == 0) }
allow
{
map[location+mapwidth] = map[location];
map[location] = 0;
location = location + mapwidth;
}
label { "key_s" }
when { (map[location-mapwidth] == 0) }
allow
{
map[location-mapwidth] = map[location];
map[location] = 0;
location = location - mapwidth;
}
label { "key_w" }
}
display
{
stringtable counters {".", "#", "@"}
box {content {"Pseudo-Doom"}}
newline
// Draw the grid
for y ( 0 .. (mapheight-1) )
{
for x ( 0 .. (mapwidth-1) )
{
box
{
width { 1.1em }
height { 1em }
content { counters[ map[(y*mapwidth)+x] ] }
}
}
newline
}
newline
// Controls
box
{
width { 2em }
height { 1em }
border { 1px solid black }
content { "q" }
bind_action { "key_q" }
}
box
{
width { 2em }
height { 1em }
border { 1px solid black }
content { "w" }
bind_action { "key_w" }
}
box
{
width { 2em }
height { 1em }
border { 1px solid black }
content { "e" }
bind_action { "key_e" }
}
newline
box //Spacer for that Authentic Keyboard Look (TM)
{
width { 0.6em }
height { 1em }
}
box
{
width { 2em }
height { 1em }
border { 1px solid black }
content { "a" }
bind_action { "key_a" }
}
box
{
width { 2em }
height { 1em }
border { 1px solid black }
content { "s" }
bind_action { "key_s" }
}
box
{
width { 2em }
height { 1em }
border { 1px solid black }
content { "d" }
bind_action { "key_d" }
}
newline
box
{
content{ "WASD... Now all we need is 3D and we'll have Quake in no time..." }
}
}