Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
nop90 committed May 31, 2016
1 parent fa2abc4 commit fee9831
Show file tree
Hide file tree
Showing 5 changed files with 852 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -29,8 +29,8 @@ include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
TARGET := ZeldaROTH
BUILD := build
SOURCES := src src/3ds src/fmmidi
INCLUDES := src src/3ds src/fmmidi
SOURCES := src src/3ds
INCLUDES := src src/3ds
ROMFS := data

APP_TITLE := Zelda ROTH
Expand Down
84 changes: 84 additions & 0 deletions src/Bouclier.cpp
@@ -0,0 +1,84 @@
/*
Zelda Return of the Hylian
Copyright (C) 2005-2008 Vincent Jouillat
Please send bugreports with examples or suggestions to www.zeldaroth.fr
*/

#include "Bouclier.h"
#include "Common.h"
#include "3ds/gfx_3ds.h"


Bouclier::Bouclier(SDL_Surface* img, int id) : image(img), type(id) {
SDL_SetColorKey(image,SDL_SRCCOLORKEY,SDL_MapRGB(image->format,0,0,255));
zone = NULL;
}

Bouclier::~Bouclier() {
SDL_FreeSurface(image);
delete zone;
}

void Bouclier::draw(SDL_Surface* screen, int x, int y, ZoneRect* z, int direction) {
setZone(z);

if (type == 2) {
switch (direction) {
case N :
zone->getZone()->x--; zone->getZone()->y-=2;
zone->getZone()->w+=3; zone->getZone()->h+=2;
break;
case S :
zone->getZone()->x-=2; zone->getZone()->y-=2;
zone->getZone()->w+=3; zone->getZone()->h+=2;
x+=3;
break;
case O :
case E :
x+=6;
zone->getZone()->y--; zone->getZone()->h+=2;
break;
}
}
if (type == 3) {
switch (direction) {
case N :
zone->getZone()->x-=2; zone->getZone()->y-=4;
zone->getZone()->w+=5; zone->getZone()->h+=5;
break;
case S :
zone->getZone()->x-=3; zone->getZone()->y-=4;
zone->getZone()->w+=5; zone->getZone()->h+=5;
x+=5;
break;
case O :
case E :
x+=10;
zone->getZone()->y--; zone->getZone()->h+=4;
break;
}
}


SDL_Rect src;
src.x = x;
src.y = y;
src.w = zone->getZone()->w;
src.h = zone->getZone()->h;

SDL_Rect dst;
dst.x = zone->getZone()->x;
dst.y = zone->getZone()->y;

SDL_BlitSurface(image, &src, screen, &dst);

}

void Bouclier::setZone(ZoneRect* z) {
delete zone;
zone = z;
}

0 comments on commit fee9831

Please sign in to comment.