A WIP Roguelike game by Adekto, VonBednat, Trelemar and Wuuff made for CGAJam in spring 2017

Dependencies:   PokittoLib

Fork of Arcade by Pokitto Community Team

Committer:
Pokitto
Date:
Mon May 21 18:04:18 2018 +0000
Revision:
15:67fb7b0c1149
Parent:
10:590a26231903
Compilation working now. Get music from: https://talk.pokitto.com/t/game-columns-coffins-roguelike-updated/482

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 10:590a26231903 1 bool colide(int id, int x, int y, bool c){
Pokitto 10:590a26231903 2 if (entities[id].x == x && entities[id].y == y) return false;
Pokitto 10:590a26231903 3 else return c;
Pokitto 10:590a26231903 4 }
Pokitto 10:590a26231903 5 bool bonycolide(int x, int y){
Pokitto 10:590a26231903 6 for(int i=0; i<entities.size(); ++i){
Pokitto 10:590a26231903 7 if (entities[i].x == x && entities[i].y == y) return false;
Pokitto 10:590a26231903 8 }
Pokitto 10:590a26231903 9 return true;
Pokitto 10:590a26231903 10 }
Pokitto 10:590a26231903 11 bool entitiesLogic(int playerX, int playerY){
Pokitto 10:590a26231903 12 bool nocolide = true;
Pokitto 10:590a26231903 13
Pokitto 10:590a26231903 14 for(int i=0; i<entities.size(); ++i){
Pokitto 10:590a26231903 15
Pokitto 10:590a26231903 16 switch(entities[i].id){
Pokitto 10:590a26231903 17 case ID_BLOOD:
Pokitto 10:590a26231903 18 if(rand()%10 == 1) entities[i].id = ID_BLOOD_SKELETON;
Pokitto 10:590a26231903 19 break;
Pokitto 10:590a26231903 20 case ID_SCROLL:
Pokitto 10:590a26231903 21 playerHP += rand()%100;
Pokitto 10:590a26231903 22 if(playerHP > 100){playerHP = 100;}
Pokitto 10:590a26231903 23 sprintf(printer,"scroll of healing");
Pokitto 10:590a26231903 24 break;
Pokitto 10:590a26231903 25 case ID_CHEST:
Pokitto 10:590a26231903 26 nocolide = colide(i,playerX,playerY,nocolide); //its wierd but works
Pokitto 10:590a26231903 27 if(!colide(i,playerX,playerY,true)){
Pokitto 10:590a26231903 28 entities[i].id = ID_CHEST_OPEN;
Pokitto 10:590a26231903 29 sprintf(printer,"open chest, taken %i gold", entities[i].hp);
Pokitto 10:590a26231903 30 playerGold += entities[i].hp;
Pokitto 10:590a26231903 31 entities[i].hp = 0;
Pokitto 10:590a26231903 32 }
Pokitto 10:590a26231903 33 break;
Pokitto 10:590a26231903 34 case ID_CHEST_OPEN:
Pokitto 10:590a26231903 35
Pokitto 10:590a26231903 36
Pokitto 10:590a26231903 37 break;
Pokitto 10:590a26231903 38 case ENTITY_TILES + 15:
Pokitto 10:590a26231903 39 case ENTITY_TILES + 16:
Pokitto 10:590a26231903 40 case ENTITY_TILES + 17:
Pokitto 10:590a26231903 41 case ENTITY_TILES + 18:
Pokitto 10:590a26231903 42 case ENTITY_TILES + 19:
Pokitto 10:590a26231903 43 case ENTITY_TILES + 20:
Pokitto 10:590a26231903 44 case ID_BLOOD_SKELETON:
Pokitto 10:590a26231903 45 case ID_RAT:
Pokitto 10:590a26231903 46 case ID_GOBLIN_WARRIOR:
Pokitto 10:590a26231903 47 case ID_GOBLIN_MAGE:
Pokitto 10:590a26231903 48 case ID_SKELETON_MAGE:
Pokitto 10:590a26231903 49 case ID_SKELETON_ARCHER:
Pokitto 10:590a26231903 50 case ID_SKELETON_WARIOR:
Pokitto 10:590a26231903 51 case ID_MIMIC:
Pokitto 10:590a26231903 52 nocolide = colide(i,playerX,playerY,nocolide); //its wierd but works
Pokitto 10:590a26231903 53 if(entities[i].x > playerX && colide(i,playerX+1,playerY,true)){
Pokitto 10:590a26231903 54 if (!solids[dungeon[entities[i].y][entities[i].x-1]]){
Pokitto 10:590a26231903 55 if(bonycolide(entities[i].x-1, entities[i].y)) entities[i].x-=1;}
Pokitto 10:590a26231903 56 }
Pokitto 10:590a26231903 57 else if(!colide(i,playerX+1,playerY,true)) playerHP -=10;
Pokitto 10:590a26231903 58
Pokitto 10:590a26231903 59 if(entities[i].x < playerX && colide(i,playerX-1,playerY,true)){
Pokitto 10:590a26231903 60 if (!solids[dungeon[entities[i].y][entities[i].x+1]]){
Pokitto 10:590a26231903 61 if(bonycolide(entities[i].x+1, entities[i].y)) entities[i].x+=1;}
Pokitto 10:590a26231903 62 }
Pokitto 10:590a26231903 63 else if(!colide(i,playerX-1,playerY,true)) playerHP -=10;
Pokitto 10:590a26231903 64
Pokitto 10:590a26231903 65 if(entities[i].y > playerY && colide(i,playerX,playerY+1,true)){
Pokitto 10:590a26231903 66 if (!solids[dungeon[entities[i].y-1][entities[i].x]])
Pokitto 10:590a26231903 67 {
Pokitto 10:590a26231903 68 if(bonycolide(entities[i].x, entities[i].y-1)) entities[i].y-=1;}
Pokitto 10:590a26231903 69 }
Pokitto 10:590a26231903 70 else if(!colide(i,playerX,playerY+1,true)) playerHP -=10;
Pokitto 10:590a26231903 71
Pokitto 10:590a26231903 72 if(entities[i].y < playerY && colide(i,playerX,playerY-1,true)){
Pokitto 10:590a26231903 73 if (!solids[dungeon[entities[i].y+1][entities[i].x]]){
Pokitto 10:590a26231903 74 if(bonycolide(entities[i].x, entities[i].y+1)) entities[i].y+=1;}
Pokitto 10:590a26231903 75 }
Pokitto 10:590a26231903 76 else if(!colide(i,playerX,playerY-1,true)) playerHP -=10;
Pokitto 10:590a26231903 77
Pokitto 10:590a26231903 78 if(!colide(i,playerX,playerY,true)){
Pokitto 10:590a26231903 79 entities[i].hp -= 1;
Pokitto 10:590a26231903 80
Pokitto 10:590a26231903 81 switch(entities[i].id){
Pokitto 10:590a26231903 82 case ID_BLOOD_SKELETON:
Pokitto 10:590a26231903 83 sprintf(printer,"hit blood skeleton, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 84 break;
Pokitto 10:590a26231903 85 case ID_RAT:
Pokitto 10:590a26231903 86 sprintf(printer,"hit giant rat, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 87 break;
Pokitto 10:590a26231903 88 case ID_GOBLIN_WARRIOR:
Pokitto 10:590a26231903 89 sprintf(printer,"hit goblin warrior, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 90 break;
Pokitto 10:590a26231903 91 case ID_GOBLIN_MAGE:
Pokitto 10:590a26231903 92 sprintf(printer,"hit goblin mage, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 93 break;
Pokitto 10:590a26231903 94 case ID_SKELETON_MAGE:
Pokitto 10:590a26231903 95 sprintf(printer,"hit skeleton mage, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 96 break;
Pokitto 10:590a26231903 97 case ID_SKELETON_ARCHER:
Pokitto 10:590a26231903 98 sprintf(printer,"hit skeleton archer, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 99 break;
Pokitto 10:590a26231903 100 case ID_SKELETON_WARIOR:
Pokitto 10:590a26231903 101 sprintf(printer,"hit skeleton warior, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 102 break;
Pokitto 10:590a26231903 103 case ID_MIMIC:
Pokitto 10:590a26231903 104 sprintf(printer,"hit mimic, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 105 break;
Pokitto 10:590a26231903 106 case ENTITY_TILES + 15:
Pokitto 10:590a26231903 107 sprintf(printer,"hit zombie, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 108 break;
Pokitto 10:590a26231903 109 case ENTITY_TILES + 16:
Pokitto 10:590a26231903 110 sprintf(printer,"hit bloated zombie, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 111 break;
Pokitto 10:590a26231903 112 case ENTITY_TILES + 17:
Pokitto 10:590a26231903 113 sprintf(printer,"hit fog, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 114 break;
Pokitto 10:590a26231903 115 case ENTITY_TILES + 18:
Pokitto 10:590a26231903 116 sprintf(printer,"hit spirit, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 117 break;
Pokitto 10:590a26231903 118 case ENTITY_TILES + 19:
Pokitto 10:590a26231903 119 sprintf(printer,"hit spawn, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 120 break;
Pokitto 10:590a26231903 121 case ENTITY_TILES + 20:
Pokitto 10:590a26231903 122 sprintf(printer,"hit giant worm, hp: %i", entities[i].hp);
Pokitto 10:590a26231903 123 break;
Pokitto 10:590a26231903 124 }
Pokitto 10:590a26231903 125 if(entities[i].hp <= 0 && entities[i].id == ID_BLOOD_SKELETON){
Pokitto 10:590a26231903 126 entities[i].id = ID_BLOOD;
Pokitto 10:590a26231903 127 entities[i].hp = rand()%5;
Pokitto 10:590a26231903 128 }
Pokitto 10:590a26231903 129 else if(entities[i].hp <= 0){
Pokitto 10:590a26231903 130
Pokitto 10:590a26231903 131 int tpgold = rand()%5;
Pokitto 10:590a26231903 132 playerGold += tpgold;
Pokitto 10:590a26231903 133 sprintf(printer,"killed enemy, gained %i gold", tpgold);
Pokitto 10:590a26231903 134 removeEntity(i);
Pokitto 10:590a26231903 135 }
Pokitto 10:590a26231903 136
Pokitto 10:590a26231903 137 }
Pokitto 10:590a26231903 138 break;
Pokitto 10:590a26231903 139 default:
Pokitto 10:590a26231903 140 printf("unknown entety %i\n", entities[i].id);
Pokitto 10:590a26231903 141 break;
Pokitto 10:590a26231903 142 }
Pokitto 10:590a26231903 143 }
Pokitto 10:590a26231903 144 return nocolide;
Pokitto 10:590a26231903 145 }
Pokitto 10:590a26231903 146
Pokitto 15:67fb7b0c1149 147