Merge pull request #1 from RSDuck/darkness
Working darkness on deeper levels
This commit is contained in:
commit
db7fecdf4d
7 changed files with 1572 additions and 916 deletions
11
.gitignore
vendored
11
.gitignore
vendored
|
@ -41,3 +41,14 @@ $RECYCLE.BIN/
|
|||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# 3DS Dev
|
||||
*.3dsx
|
||||
*.elf
|
||||
*.smdh
|
||||
build
|
||||
|
||||
# Eclipse
|
||||
.settings
|
||||
.cproject
|
||||
.project
|
||||
|
|
|
@ -48,7 +48,6 @@ bool screenShot;
|
|||
extern char versionText[34];
|
||||
|
||||
Entity player;
|
||||
sf2d_texture * lightScreen;
|
||||
|
||||
sf2d_texture * minimap[5];
|
||||
u8 map[5][128*128];
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include "Sound.h"
|
||||
|
||||
|
|
|
@ -764,7 +764,7 @@ void renderMenu(int menu,int xscr,int yscr){
|
|||
sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
|
||||
}
|
||||
offsetX = xscr;offsetY = yscr;
|
||||
renderBackground(xscr,yscr);
|
||||
renderMenuBackground(xscr,yscr);
|
||||
offsetX = 0;offsetY = 0;
|
||||
renderFrame(1,1,24,14,0xAF1010FF);
|
||||
drawText("Paused",164,32);
|
||||
|
@ -797,7 +797,7 @@ void renderMenu(int menu,int xscr,int yscr){
|
|||
sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
|
||||
}
|
||||
offsetX = xscr;offsetY = yscr;
|
||||
renderBackground(xscr,yscr);
|
||||
renderMenuBackground(xscr,yscr);
|
||||
offsetX = 0;offsetY = 0;
|
||||
renderFrame(5,3,21,12,0x1010FFFF);
|
||||
if(!rev){ opacity+=5; if(opacity == 255) rev = true; }
|
||||
|
@ -818,7 +818,7 @@ void renderMenu(int menu,int xscr,int yscr){
|
|||
sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
|
||||
}
|
||||
offsetX = xscr;offsetY = yscr;
|
||||
renderBackground(xscr,yscr);
|
||||
renderMenuBackground(xscr,yscr);
|
||||
offsetX = 0;offsetY = 0;
|
||||
renderFrame(5,3,21,12,0x1010FFFF);
|
||||
if(!rev){ opacity+=5; if(opacity == 255) rev = true; }
|
||||
|
@ -838,7 +838,7 @@ void renderMenu(int menu,int xscr,int yscr){
|
|||
sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
|
||||
}
|
||||
offsetX = xscr;offsetY = yscr;
|
||||
renderBackground(xscr,yscr);
|
||||
renderMenuBackground(xscr,yscr);
|
||||
offsetX = 0;offsetY = 0;
|
||||
renderFrame(1,1,24,14,0x1010FFFF);
|
||||
renderItemList(player.p.inv, 1,1,24,14, curInvSel);
|
||||
|
@ -851,7 +851,7 @@ void renderMenu(int menu,int xscr,int yscr){
|
|||
sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
|
||||
}
|
||||
offsetX = xscr;offsetY = yscr;
|
||||
renderBackground(xscr,yscr);
|
||||
renderMenuBackground(xscr,yscr);
|
||||
offsetX = 0;offsetY = 0;
|
||||
|
||||
renderFrame(15,1,24,4,0x1010FFFF);
|
||||
|
@ -887,7 +887,7 @@ void renderMenu(int menu,int xscr,int yscr){
|
|||
sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
|
||||
}
|
||||
offsetX = xscr;offsetY = yscr;
|
||||
renderBackground(xscr,yscr);
|
||||
renderMenuBackground(xscr,yscr);
|
||||
if (curChestEntity->entityFurniture.r == 1){ offsetX = 48;offsetY = 0;}
|
||||
else {offsetX = 0;offsetY = 0;}
|
||||
|
||||
|
|
1554
source/Render.c
1554
source/Render.c
File diff suppressed because it is too large
Load diff
|
@ -9,28 +9,36 @@
|
|||
|
||||
sf2d_texture *icons;
|
||||
sf2d_texture *font;
|
||||
sf2d_texture *lightScreen;
|
||||
sf2d_texture *playerLightBake;
|
||||
sf2d_texture *lanternLightBake;
|
||||
int offsetX, offsetY;
|
||||
|
||||
void render(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits);
|
||||
void renderb(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits, u32 color);
|
||||
void renderr(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits,float rotate);
|
||||
void renderc(s32 xp, s32 yp, u32 xTile, u32 yTile,int sizeX, int sizeY, u8 bits);
|
||||
void renderbc(s32 xp, s32 yp, u32 xTile, u32 yTile,int sizeX, int sizeY, u8 bits, u32 color);
|
||||
void renderr(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits, float rotate);
|
||||
void renderc(s32 xp, s32 yp, u32 xTile, u32 yTile, int sizeX, int sizeY,
|
||||
u8 bits);
|
||||
void renderbc(s32 xp, s32 yp, u32 xTile, u32 yTile, int sizeX, int sizeY,
|
||||
u8 bits, u32 color);
|
||||
void render16(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits);
|
||||
void render16c(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits,float scaleX,float scaleY);
|
||||
void render16b(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits,u32 color);
|
||||
void render16s(s32 xp, s32 yp, u32 tile, u8 bits,u32 color);
|
||||
void render16c(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits, float scaleX,
|
||||
float scaleY);
|
||||
void render16b(s32 xp, s32 yp, u32 xTile, u32 yTile, u8 bits, u32 color);
|
||||
void render16s(s32 xp, s32 yp, u32 tile, u8 bits, u32 color);
|
||||
|
||||
void renderTitle(int x, int y);
|
||||
void renderFrame(int x1, int y1, int x2, int y2, u32 bgColor);
|
||||
void renderTile(int i, int x, int y);
|
||||
void renderBackground(int xScroll, int yScroll);
|
||||
void renderMenuBackground(int xScroll, int yScroll); //Renders the darkness
|
||||
void renderButtonIcon(u32 icon, int x, int y, float scale);
|
||||
|
||||
void renderLights();
|
||||
void renderLight(int x, int y, int r);
|
||||
void renderLightScreen();
|
||||
void bakeLights();
|
||||
void freeLightBakes();
|
||||
void renderLightsToStencil();
|
||||
void resetStencilStuff();
|
||||
void bakeLight(sf2d_texture* texture, int x, int y, int r);
|
||||
void renderLight(int x, int y, sf2d_texture* texture);
|
||||
|
||||
void renderGui();
|
||||
void renderPlayer();
|
||||
|
@ -45,8 +53,10 @@ void renderFurniture(int itemID, int x, int y);
|
|||
void renderEntity(Entity* e, int x, int y);
|
||||
void renderEntities(int x, int y, EntityManager* em);
|
||||
|
||||
void renderRecipes(RecipeManager * r,int xo, int yo, int x1, int y1, int selected);
|
||||
void renderItemList(Inventory * inv,int xo, int yo, int x1, int y1, int selected);
|
||||
void renderRecipes(RecipeManager * r, int xo, int yo, int x1, int y1,
|
||||
int selected);
|
||||
void renderItemList(Inventory * inv, int xo, int yo, int x1, int y1,
|
||||
int selected);
|
||||
void renderItemWithText(Item* item, int x, int y);
|
||||
void renderItemIcon(int itemID, int countLevel, int x, int y);
|
||||
void renderItemIcon2(int itemID, int countLevel, int x, int y, int z);
|
||||
|
|
255
source/main.c
255
source/main.c
|
@ -15,110 +15,144 @@
|
|||
#include "MapGen.h"
|
||||
#include "Menu.h"
|
||||
|
||||
void initMiniMap(bool loadUpWorld) {
|
||||
int i, x, y;
|
||||
for (i = 0; i < 5; ++i) {
|
||||
for (x = 0; x < 128; ++x) {
|
||||
for (y = 0; y < 128; ++y) {
|
||||
|
||||
void initMiniMap(bool loadUpWorld){
|
||||
int i,x,y;
|
||||
for(i=0;i<5;++i){
|
||||
for(x=0;x < 128;++x){
|
||||
for(y=0;y < 128;++y){
|
||||
|
||||
if(!loadUpWorld){ // generate stairs up when making a new world.
|
||||
switch(map[i][x+y*128]){
|
||||
if (!loadUpWorld) { // generate stairs up when making a new world.
|
||||
switch (map[i][x + y * 128]) {
|
||||
case TILE_STAIRS_DOWN:
|
||||
map[i+1][x+y*128] = TILE_STAIRS_UP;
|
||||
if(i == 0){
|
||||
map[i+1][(x+1)+y*128] = TILE_HARDROCK;
|
||||
map[i+1][x+(y+1)*128] = TILE_HARDROCK;
|
||||
map[i+1][(x-1)+y*128] = TILE_HARDROCK;
|
||||
map[i+1][x+(y-1)*128] = TILE_HARDROCK;
|
||||
map[i+1][(x+1)+(y+1)*128] = TILE_HARDROCK;
|
||||
map[i+1][(x-1)+(y-1)*128] = TILE_HARDROCK;
|
||||
map[i+1][(x-1)+(y+1)*128] = TILE_HARDROCK;
|
||||
map[i+1][(x+1)+(y-1)*128] = TILE_HARDROCK;
|
||||
map[i + 1][x + y * 128] = TILE_STAIRS_UP;
|
||||
if (i == 0) {
|
||||
map[i + 1][(x + 1) + y * 128] = TILE_HARDROCK;
|
||||
map[i + 1][x + (y + 1) * 128] = TILE_HARDROCK;
|
||||
map[i + 1][(x - 1) + y * 128] = TILE_HARDROCK;
|
||||
map[i + 1][x + (y - 1) * 128] = TILE_HARDROCK;
|
||||
map[i + 1][(x + 1) + (y + 1) * 128] = TILE_HARDROCK;
|
||||
map[i + 1][(x - 1) + (y - 1) * 128] = TILE_HARDROCK;
|
||||
map[i + 1][(x - 1) + (y + 1) * 128] = TILE_HARDROCK;
|
||||
map[i + 1][(x + 1) + (y - 1) * 128] = TILE_HARDROCK;
|
||||
} else {
|
||||
map[i+1][(x+1)+y*128] = TILE_DIRT;
|
||||
map[i+1][x+(y+1)*128] = TILE_DIRT;
|
||||
map[i+1][(x-1)+y*128] = TILE_DIRT;
|
||||
map[i+1][x+(y-1)*128] = TILE_DIRT;
|
||||
map[i+1][(x+1)+(y+1)*128] = TILE_DIRT;
|
||||
map[i+1][(x-1)+(y-1)*128] = TILE_DIRT;
|
||||
map[i+1][(x-1)+(y+1)*128] = TILE_DIRT;
|
||||
map[i+1][(x+1)+(y-1)*128] = TILE_DIRT;
|
||||
map[i + 1][(x + 1) + y * 128] = TILE_DIRT;
|
||||
map[i + 1][x + (y + 1) * 128] = TILE_DIRT;
|
||||
map[i + 1][(x - 1) + y * 128] = TILE_DIRT;
|
||||
map[i + 1][x + (y - 1) * 128] = TILE_DIRT;
|
||||
map[i + 1][(x + 1) + (y + 1) * 128] = TILE_DIRT;
|
||||
map[i + 1][(x - 1) + (y - 1) * 128] = TILE_DIRT;
|
||||
map[i + 1][(x - 1) + (y + 1) * 128] = TILE_DIRT;
|
||||
map[i + 1][(x + 1) + (y - 1) * 128] = TILE_DIRT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Minimaps */
|
||||
switch(map[i][x+y*128]){
|
||||
case TILE_WATER: sf2d_set_pixel (minimap[i], x, y, 0xFFFF0000); break;
|
||||
case TILE_LAVA: sf2d_set_pixel (minimap[i], x, y, 0xFF0000FF); break;
|
||||
case TILE_DIRT: sf2d_set_pixel (minimap[i], x, y, 0xFF6C6D82); break;
|
||||
case TILE_ROCK: sf2d_set_pixel (minimap[i], x, y, 0xFF7F7F7F); break;
|
||||
case TILE_HARDROCK: sf2d_set_pixel (minimap[i], x, y, 0xFF7F5F5F); break;
|
||||
case TILE_GRASS: sf2d_set_pixel (minimap[i], x, y, 0xFF00FF00); break;
|
||||
case TILE_TREE: sf2d_set_pixel (minimap[i], x, y, 0xFF007F00); break;
|
||||
case TILE_SAND: sf2d_set_pixel (minimap[i], x, y, 0xFF00FFFF); break;
|
||||
case TILE_CACTUS: sf2d_set_pixel (minimap[i], x, y, 0xFF009F00); break;
|
||||
case TILE_FLOWER: sf2d_set_pixel (minimap[i], x, y, 0xFF00FF3F); break;
|
||||
case TILE_IRONORE: sf2d_set_pixel (minimap[i], x, y, 0xFF9696DC); break;
|
||||
case TILE_GOLDORE: sf2d_set_pixel (minimap[i], x, y, 0xFF9AE8E5); break;
|
||||
case TILE_GEMORE: sf2d_set_pixel (minimap[i], x, y, 0xFFDE98DF); break;
|
||||
case TILE_CLOUD: sf2d_set_pixel (minimap[i], x, y, 0xFFFFFFFF); break;
|
||||
case TILE_CLOUDCACTUS: sf2d_set_pixel (minimap[i], x, y, 0xFFAFAFAF); break;
|
||||
case TILE_STAIRS_DOWN: sf2d_set_pixel (minimap[i], x, y, 0xFF9F9F9F); break;
|
||||
case TILE_STAIRS_UP: sf2d_set_pixel (minimap[i], x, y, 0xFF9F9F9F); break;
|
||||
default: sf2d_set_pixel (minimap[i], x, y, 0xFF111111); break;
|
||||
switch (map[i][x + y * 128]) {
|
||||
case TILE_WATER:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFFFF0000);
|
||||
break;
|
||||
case TILE_LAVA:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF0000FF);
|
||||
break;
|
||||
case TILE_DIRT:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF6C6D82);
|
||||
break;
|
||||
case TILE_ROCK:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF7F7F7F);
|
||||
break;
|
||||
case TILE_HARDROCK:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF7F5F5F);
|
||||
break;
|
||||
case TILE_GRASS:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF00FF00);
|
||||
break;
|
||||
case TILE_TREE:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF007F00);
|
||||
break;
|
||||
case TILE_SAND:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF00FFFF);
|
||||
break;
|
||||
case TILE_CACTUS:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF009F00);
|
||||
break;
|
||||
case TILE_FLOWER:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF00FF3F);
|
||||
break;
|
||||
case TILE_IRONORE:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF9696DC);
|
||||
break;
|
||||
case TILE_GOLDORE:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF9AE8E5);
|
||||
break;
|
||||
case TILE_GEMORE:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFFDE98DF);
|
||||
break;
|
||||
case TILE_CLOUD:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFFFFFFFF);
|
||||
break;
|
||||
case TILE_CLOUDCACTUS:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFFAFAFAF);
|
||||
break;
|
||||
case TILE_STAIRS_DOWN:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF9F9F9F);
|
||||
break;
|
||||
case TILE_STAIRS_UP:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF9F9F9F);
|
||||
break;
|
||||
default:
|
||||
sf2d_set_pixel(minimap[i], x, y, 0xFF111111);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void initNewMap(){
|
||||
void initNewMap() {
|
||||
newSeed();
|
||||
createAndValidateSkyMap(128,128,map[0],data[0]);
|
||||
createAndValidateTopMap(128,128,map[1],data[1]);
|
||||
createAndValidateUndergroundMap(128,128,1,map[2],data[2]);
|
||||
createAndValidateUndergroundMap(128,128,2,map[3],data[3]);
|
||||
createAndValidateUndergroundMap(128,128,3,map[4],data[4]);
|
||||
createAndValidateSkyMap(128, 128, map[0], data[0]);
|
||||
createAndValidateTopMap(128, 128, map[1], data[1]);
|
||||
createAndValidateUndergroundMap(128, 128, 1, map[2], data[2]);
|
||||
createAndValidateUndergroundMap(128, 128, 2, map[3], data[3]);
|
||||
createAndValidateUndergroundMap(128, 128, 3, map[4], data[4]);
|
||||
}
|
||||
|
||||
void setupGame(bool loadUpWorld){
|
||||
void setupGame(bool loadUpWorld) {
|
||||
currentLevel = 1;
|
||||
|
||||
// Reset entity manager.
|
||||
memset(&eManager, 0, sizeof(eManager));
|
||||
sf2d_set_clear_color(RGBA8(0x82, 0x6D, 0x6C, 0xFF));
|
||||
|
||||
if(!loadUpWorld){
|
||||
if (!loadUpWorld) {
|
||||
initNewMap();
|
||||
initPlayer();
|
||||
airWizardHealthDisplay = 2000;
|
||||
int i;
|
||||
for(i=0;i<5;++i){
|
||||
for (i = 0; i < 5; ++i) {
|
||||
trySpawn(500, i);
|
||||
}
|
||||
addEntityToList(newAirWizardEntity(630,820,0), &eManager);
|
||||
addEntityToList(newAirWizardEntity(630, 820, 0), &eManager);
|
||||
} else {
|
||||
initPlayer();
|
||||
loadWorld(currentFileName, &eManager, &player, (u8*)map, (u8*)data);
|
||||
loadWorld(currentFileName, &eManager, &player, (u8*) map, (u8*) data);
|
||||
}
|
||||
|
||||
initMiniMap(loadUpWorld);
|
||||
initGame = 0;
|
||||
}
|
||||
|
||||
|
||||
int xscr=0, yscr=0;
|
||||
void tick(){
|
||||
if(player.p.isDead){
|
||||
if(player.p.endTimer < 1){
|
||||
int xscr = 0, yscr = 0;
|
||||
void tick() {
|
||||
if (player.p.isDead) {
|
||||
if (player.p.endTimer < 1) {
|
||||
currentMenu = MENU_LOSE;
|
||||
}
|
||||
--player.p.endTimer;
|
||||
return;
|
||||
} else if(player.p.hasWon){
|
||||
if(player.p.endTimer < 1){
|
||||
} else if (player.p.hasWon) {
|
||||
if (player.p.endTimer < 1) {
|
||||
currentMenu = MENU_WIN;
|
||||
}
|
||||
--player.p.endTimer;
|
||||
|
@ -126,37 +160,45 @@ void tick(){
|
|||
}
|
||||
|
||||
int i;
|
||||
for(i = 0;i < 324;++i){
|
||||
for (i = 0; i < 324; ++i) {
|
||||
int xx = rand() & 127;
|
||||
int yy = rand() & 127;
|
||||
tickTile(xx,yy);
|
||||
tickTile(xx, yy);
|
||||
}
|
||||
tickPlayer();
|
||||
xscr = player.x - 100;
|
||||
yscr = player.y - 56;
|
||||
if (xscr < 16) xscr = 16; else if (xscr > 1832) xscr = 1832;
|
||||
if (yscr < 16) yscr = 16; else if (yscr > 1912) yscr = 1912;
|
||||
if (xscr < 16)
|
||||
xscr = 16;
|
||||
else if (xscr > 1832)
|
||||
xscr = 1832;
|
||||
if (yscr < 16)
|
||||
yscr = 16;
|
||||
else if (yscr > 1912)
|
||||
yscr = 1912;
|
||||
|
||||
for(i = 0; i < eManager.lastSlot[currentLevel]; ++i){
|
||||
for (i = 0; i < eManager.lastSlot[currentLevel]; ++i) {
|
||||
Entity * e = &eManager.entities[currentLevel][i];
|
||||
if((e->type != ENTITY_ZOMBIE && e->type != ENTITY_SLIME) || (e->x > player.x-160 && e->y > player.y-125 && e->x<player.x+160 && e->y<player.y+125)) tickEntity(e);
|
||||
if ((e->type != ENTITY_ZOMBIE && e->type != ENTITY_SLIME)
|
||||
|| (e->x > player.x - 160 && e->y > player.y - 125
|
||||
&& e->x < player.x + 160 && e->y < player.y + 125))
|
||||
tickEntity(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void clearScreen(int* data, u8 fill, int size){
|
||||
void clearScreen(int* data, u8 fill, int size) {
|
||||
int i;
|
||||
for (i=0; i < size/4; ++i) data[i] = 0x000000FF;
|
||||
for (i = 0; i < size / 4; ++i)
|
||||
data[i] = 0x000000FF;
|
||||
}
|
||||
|
||||
|
||||
char debugText[34];
|
||||
char bossHealthText[34];
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
sf2d_init();
|
||||
csndInit();
|
||||
noItem = newItem(ITEM_NULL,0);
|
||||
noItem = newItem(ITEM_NULL, 0);
|
||||
|
||||
currentMenu = MENU_TITLE;
|
||||
currentSelection = 0;
|
||||
|
@ -176,9 +218,12 @@ int main()
|
|||
loadSound(&snd_bossdeath, "resources/bossdeath.raw");
|
||||
loadSound(&snd_craft, "resources/craft.raw");
|
||||
|
||||
bakeLights();
|
||||
|
||||
int i;
|
||||
for(i = 0;i < 5;++i){
|
||||
minimap[i] = sf2d_create_texture(128,128,TEXFMT_RGBA8,SF2D_PLACE_RAM);
|
||||
for (i = 0; i < 5; ++i) {
|
||||
minimap[i] = sf2d_create_texture(128, 128, TEXFMT_RGBA8,
|
||||
SF2D_PLACE_RAM);
|
||||
sf2d_texture_tile32(minimap[i]);
|
||||
}
|
||||
|
||||
|
@ -200,7 +245,7 @@ int main()
|
|||
FILE * file;
|
||||
|
||||
/* If btnSave exists, then use that. */
|
||||
if ((file = fopen("btnSave.bin", "rb"))){
|
||||
if ((file = fopen("btnSave.bin", "rb"))) {
|
||||
fread(&k_up.input, sizeof(int), 1, file);
|
||||
fread(&k_down.input, sizeof(int), 1, file);
|
||||
fread(&k_left.input, sizeof(int), 1, file);
|
||||
|
@ -216,56 +261,72 @@ int main()
|
|||
|
||||
//screenShot = false;
|
||||
|
||||
tickCount=0;
|
||||
tickCount = 0;
|
||||
initRecipes();
|
||||
defineTables();
|
||||
while (aptMainLoop()) {
|
||||
++tickCount;
|
||||
hidScanInput();
|
||||
tickKeys(hidKeysHeld(),hidKeysDown());
|
||||
tickKeys(hidKeysHeld(), hidKeysDown());
|
||||
|
||||
//if (quitGame || hidKeysHeld() & KEY_SELECT) break;
|
||||
if (quitGame) break;
|
||||
if (quitGame)
|
||||
break;
|
||||
//if (hidKeysDown() & (KEY_L | KEY_R)) screenShot = true;
|
||||
// else screenShot = false;
|
||||
|
||||
if(initGame > 0) setupGame(initGame == 1 ? true : false);
|
||||
if (initGame > 0)
|
||||
setupGame(initGame == 1 ? true : false);
|
||||
|
||||
if(currentMenu == 0){
|
||||
if (currentMenu == 0) {
|
||||
tick();
|
||||
sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(),player.x, player.y,eManager.lastSlot[currentLevel]);
|
||||
sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(),
|
||||
player.x, player.y, eManager.lastSlot[currentLevel]);
|
||||
sf2d_start_frame(GFX_TOP, GFX_LEFT);
|
||||
if(currentLevel == 0){
|
||||
sf2d_draw_texture_part_scale(minimap[1],(-xscr/3)-256,(-yscr/3)-32,0,0,128,128,12.5,7.5);
|
||||
sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
|
||||
if (currentLevel == 0) {
|
||||
sf2d_draw_texture_part_scale(minimap[1], (-xscr / 3) - 256,
|
||||
(-yscr / 3) - 32, 0, 0, 128, 128, 12.5, 7.5);
|
||||
//sf2d_draw_rectangle(0, 0, 400, 240, 0xDFDFDFAF);
|
||||
}
|
||||
offsetX = xscr;offsetY = yscr;
|
||||
renderBackground(xscr,yscr);
|
||||
|
||||
offsetX = xscr;
|
||||
offsetY = yscr;
|
||||
//if(currentLevel)
|
||||
sf2d_draw_rectangle(0, 0, 400, 240, RGBA8(12, 12, 12, 255)); //You might think "real" black would be better, but it actually looks better that way
|
||||
renderLightsToStencil();
|
||||
|
||||
renderBackground(xscr, yscr);
|
||||
renderEntities(player.x, player.y, &eManager);
|
||||
renderPlayer();
|
||||
offsetX = 0;offsetY = 0;
|
||||
|
||||
resetStencilStuff();
|
||||
offsetX = 0;
|
||||
offsetY = 0;
|
||||
renderItemWithText(player.p.activeItem, 10, 205);
|
||||
// drawText(debugText,2,208);
|
||||
drawText(fpsstr,2,225);
|
||||
drawText(fpsstr, 2, 225);
|
||||
sf2d_end_frame();
|
||||
|
||||
sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
|
||||
if(currentLevel == 0 && airWizardHealthDisplay > 0){
|
||||
sprintf(bossHealthText, "BOSS: %.0f%%", ((float)airWizardHealthDisplay/2000.0)*100);
|
||||
drawText(bossHealthText,2,225);
|
||||
if (currentLevel == 0 && airWizardHealthDisplay > 0) {
|
||||
sprintf(bossHealthText, "BOSS: %.0f%%",
|
||||
((float) airWizardHealthDisplay / 2000.0) * 100);
|
||||
drawText(bossHealthText, 2, 225);
|
||||
}
|
||||
renderGui();
|
||||
sf2d_draw_texture(minimap[currentLevel], 192, 112);//y:56
|
||||
sf2d_draw_texture(minimap[currentLevel], 192, 112); //y:56
|
||||
sf2d_end_frame();
|
||||
} else{
|
||||
} else {
|
||||
tickMenu(currentMenu);
|
||||
renderMenu(currentMenu,xscr,yscr);
|
||||
renderMenu(currentMenu, xscr, yscr);
|
||||
}
|
||||
|
||||
sf2d_swapbuffers();
|
||||
}
|
||||
|
||||
freeRecipes();
|
||||
|
||||
freeLightBakes();
|
||||
sf2d_free_texture(icons);
|
||||
sf2d_free_texture(minimap[0]);
|
||||
sf2d_free_texture(minimap[1]);
|
||||
|
|
Loading…
Add table
Reference in a new issue