Skip to content

Commit

Permalink
Merge branch 'master' of gitlab.com:daniiki/fopra-robotik
Browse files Browse the repository at this point in the history
  • Loading branch information
daniiki committed Sep 18, 2017
2 parents 45c5ce7 + a635002 commit dd11ba2
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 50 deletions.
40 changes: 17 additions & 23 deletions master/dfs.c
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
#include "dfs.h"
#include "level.h"

uint8_t platform_above(uint8_t x, uint8_t y)
// whether there is a platform/foor below
bool stand_on(uint8_t x, uint8_t y)
{
if (doors & 0b00000010 && x == 0 && y == 0) // blocked by door
return 1;
else if (doors & 0b00000001 && x == GRAPH_WIDTH - 1 && y == 0)
return 1;
else if (y == 0)
return !(platforms_19 & (3l << (x * 2)));
// cannot stand on door, therefore this is different from below
if (y == 0)
// return 1 if there is a floor on the left AND on the right
return (nofloor & (3l << PLATFORM_WIDTH * x / 16 * 2)) && (nofloor & (3l << (PLATFORM_WIDTH * (x + 1) - 1) / 16 * 2));
else if (y == 1)
return !(platforms_19 & (3l << (x * 2)));
else if (y == 2)
return !(platforms_13 & (3l << (x * 2)));
return 0;
}

// whether there iss a platform/foor below
uint8_t platform_below(uint8_t x, uint8_t y)
bool blocked(uint8_t x, uint8_t y)
{
if (doors & 0b00000010 && x == 0 && y == 1) // blocked by door
return 1;
else if (doors & 0b00000001 && x == GRAPH_WIDTH - 1 && y == 1)
return 1;
if (y == 0)
// return 1 if there is a floor on the left AND on the right
return (nofloor & (3l << PLATFORM_WIDTH * x / 16 * 2)) && (nofloor & (3l << (PLATFORM_WIDTH * (x + 1) - 1) / 16 * 2));
else if (y == 1)
return !(platforms_19 & (3l << (x * 2)));
else if (y == 2)
return !(platforms_13 & (3l << (x * 2)));
return 0;
return stand_on(x, y);
}

uint8_t is_door_reachable()
bool is_door_reachable()
{
// there are 16 different x positions for platforms
// and 3 different y positions (floor, first and second platform level)
Expand Down Expand Up @@ -81,13 +75,13 @@ uint8_t is_door_reachable()
continue;
if (visited[y + 1] & (1 << (x + i)))
continue;
if (!platform_below(x + i, y + 1)) // can't jump onto nothing
if (!stand_on(x + i, y + 1)) // can't jump onto nothing
continue;
// check if there is no platform in the way
uint8_t platform = 0;
for (int8_t j = 0; j != i; j += (i < 0 ? -1 : 1))
{
if (platform_above(x + j, y))
if (blocked(x + j, y + 1))
{
platform = 1;
break;
Expand All @@ -109,13 +103,13 @@ uint8_t is_door_reachable()
continue;
if (visited[y - 1] & (1 << (x + i)))
continue;
if (!platform_below(x + i, y - 1)) // can't jump onto nothing
if (!stand_on(x + i, y - 1)) // can't jump onto nothing
continue;
// check if there is no platform in the way
uint8_t platform = 0;
for (int8_t j = i; j != 0; j += (i < 0 ? 1 : -1))
{
if (platform_below(x + j, y))
if (blocked(x + j, y))
{
platform = 1;
break;
Expand All @@ -137,14 +131,14 @@ uint8_t is_door_reachable()
continue;
if (visited[y] & (1 << (x + i)))
continue;
if (!platform_below(x + i, y)) // can't jump into water/spikes
if (!stand_on(x + i, y)) // can't jump into water/spikes
continue;
// check if there is no platform in the way
// a platform above the current or the target position is okay
uint8_t platform = 0;
for (int8_t j = (i < 0 ? i + 1 : i - 1); j != 0; j += (i < 0 ? 1 : -1))
{
if (platform_above(x + j, y))
if (blocked(x + j, y + 1))
{
platform = 1;
break;
Expand Down
7 changes: 4 additions & 3 deletions master/dfs.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <inttypes.h>
#include <stdbool.h>

#define GRAPH_WIDTH 16
#define GRAPH_HEIGHT 3
Expand All @@ -7,7 +8,7 @@
#define UP_DISTANCE 3
#define DOWN_DISTANCE 3

uint8_t platform_above(uint8_t x, uint8_t y);
uint8_t platform_below(uint8_t x, uint8_t y);
bool platform_above(uint8_t x, uint8_t y);
bool platform_below(uint8_t x, uint8_t y);

uint8_t is_door_reachable();
bool is_door_reachable();
6 changes: 3 additions & 3 deletions master/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void newxparasite(uint8_t i) // i is the index of the dead monster
}
if (xparasites[i]->movement != HIDDEN)
{
xparasites[i]->x = monsters[i]->x + monsters[i]->width / 2;
xparasites[i]->x = monsters[i]->x + (monsters[i]->width - xparasites[i]->width) / 2;
xparasites[i]->y = monsters[i]->y;
draw(xparasites[i]);
}
Expand Down Expand Up @@ -285,11 +285,11 @@ int main(void)
{
initial_level = 0; // start a new game
clear();
drawsprite(20, 5, 8, 2, Abutton);
drawsprite(20, 5, 8, 3, Abutton);
drawletters(30, 5, "SHOOT A ROCKET");
drawsprite(20, 10, 8, 3, BButton);
drawletters(30, 10, "PLACE A BOMB");
drawsprite(20, 15, 8, 2, Pbutton);
drawsprite(20, 15, 8, 3, Pbutton);
drawletters(30, 15, "PAUSE");
drawletters(20, 20, "PRESS");
drawsprite(48, 20, 9, 3, UPButton);
Expand Down
22 changes: 9 additions & 13 deletions master/sprites.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,10 @@ const PROGMEM uint8_t A[8] = {
0b11111111, 0b00000011, 0b00000011, 0b11111111
};

const PROGMEM uint8_t Abutton[16] = {
const PROGMEM uint8_t Abutton[24] = {
0b11111100, 0b00000011, 0b11110011, 0b00110011, 0b00110011, 0b11110011, 0b00000011, 0b11111100,
0b00111111, 0b11000000, 0b11001111, 0b11000011, 0b11000011, 0b11001111, 0b11000000, 0b00111111
0b11111111, 0b00000000, 0b00111111, 0b00000011, 0b00000011, 0b00111111, 0b00000000, 0b11111111,
0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000
};

const PROGMEM uint8_t B[8] = {
Expand Down Expand Up @@ -407,9 +408,10 @@ const PROGMEM uint8_t P[8] = {
0b11111111, 0b00000000, 0b00000000, 0b00000000
};

const PROGMEM uint8_t Pbutton[16] = {
const PROGMEM uint8_t Pbutton[24] = {
0b11111100, 0b00000011, 0b11110011, 0b00110011, 0b00110011, 0b11110011, 0b00000011, 0b11111100,
0b00111111, 0b11000000, 0b11001111, 0b11000011, 0b11000011, 0b11000011, 0b11000000, 0b00111111
0b11111111, 0b00000000, 0b00111111, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b11111111,
0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000
};

const PROGMEM uint8_t Q[8] = {
Expand Down Expand Up @@ -439,7 +441,7 @@ const PROGMEM uint8_t U[8] = {

const PROGMEM uint8_t UPButton[27] = {
0b11000000, 0b11000000, 0b11000000, 0b11111111, 0b11111111, 0b11111111, 0b11000000, 0b11000000, 0b11000000,
0b00001111, 0b00001101, 0b00001101, 0b11111101, 0b01010101, 0b11111101, 0b00001101, 0b00001101, 0b00001111,
0b00001111, 0b00001100, 0b00001100, 0b11111100, 0b00000000, 0b11111100, 0b00001100, 0b00001100, 0b00001111,
0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000
};

Expand Down Expand Up @@ -589,12 +591,6 @@ const PROGMEM uint8_t rechargeright[148] = {
0b11111100, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111100, 0b11111111, 0b11111111, 0b11111111, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111111, 0b11111111, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111100, 0b11111111, 0b11111111, 0b11111100, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111100
};

const PROGMEM uint8_t restart[288] = {
0b11111111, 0b11000011, 0b11000011, 0b11000011, 0b11000011, 0b11111111, 0b00000000, 0b11111111, 0b11000011, 0b11000011, 0b11000011, 0b11111111, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000011, 0b11111111, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b11000011, 0b11000011, 0b11000011, 0b11111111, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000011, 0b00000011, 0b11111111, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b11111111, 0b11000011, 0b11000011, 0b11000011, 0b11111111, 0b00000000, 0b00000011, 0b00000011, 0b11111111, 0b00000011, 0b00000011,
0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000011, 0b00001100, 0b00110000, 0b11000000, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000011, 0b00001100, 0b00110000, 0b11000000, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b11111111, 0b00000011, 0b00001100, 0b00110000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000,
0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000
};

const PROGMEM uint8_t resume[222] = {
0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b11111111, 0b11000011, 0b11000011, 0b11000011, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101010, 0b00000010, 0b00000010, 0b00000010, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000011, 0b11111111, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b11000011, 0b11000011, 0b11000011, 0b11111111, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b11111111, 0b00001100, 0b00110000, 0b11000000, 0b00110000, 0b00001100, 0b11111111, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000011,
0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b11111111, 0b00000011, 0b00001100, 0b00110000, 0b11000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101010, 0b00000010, 0b00000010, 0b00000010, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000011, 0b00001100, 0b00110000, 0b11000000, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000011, 0b00000011, 0b00000011, 0b11111111, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b11111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00000000, 0b11111111, 0b00000011, 0b00000011, 0b00000000, 0b00000000,
Expand All @@ -619,8 +615,8 @@ const PROGMEM uint8_t six[9] = {
};

const PROGMEM uint8_t six2[6] = {
0b11111111, 0b00000011, 0b00000011,
0b11111111, 0b11000011, 0b11111111
0b11111111, 0b11000011, 0b11000011,
0b11111111, 0b11000000, 0b11111111
};

const PROGMEM uint8_t splashcenter[780] = {
Expand Down
13 changes: 5 additions & 8 deletions master/sprites.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ extern PROGMEM const uint8_t xparasite2[12];
// 8x4
extern PROGMEM const uint8_t A[8];

// 8x8
extern PROGMEM const uint8_t Abutton[16];
// 9x8
extern PROGMEM const uint8_t Abutton[24];

// 8x4
extern PROGMEM const uint8_t B[8];

// 12x8
// 9x8
extern PROGMEM const uint8_t BButton[24];

// 8x3
Expand Down Expand Up @@ -195,8 +195,8 @@ extern PROGMEM const uint8_t O[8];
// 8x4
extern PROGMEM const uint8_t P[8];

// 8x8
extern PROGMEM const uint8_t Pbutton[16];
// 9x8
extern PROGMEM const uint8_t Pbutton[24];

// 8x4
extern PROGMEM const uint8_t Q[8];
Expand Down Expand Up @@ -291,9 +291,6 @@ extern PROGMEM const uint8_t rechargeleft[272];
// 16x37
extern PROGMEM const uint8_t rechargeright[148];

// 9x96
extern PROGMEM const uint8_t restart[288];

// 9x74
extern PROGMEM const uint8_t resume[222];

Expand Down
Binary file added sprites/labels/Abutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/BButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/Pbutton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/UPButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/eight2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/five2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/four2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/nine2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/one2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed sprites/labels/restart.png
Binary file not shown.
Binary file added sprites/labels/seven2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/six2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/three2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/two2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/labels/zero2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dd11ba2

Please sign in to comment.