Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
refactoring + special bonus effects
Browse files Browse the repository at this point in the history
  • Loading branch information
biou committed Feb 16, 2014
1 parent 4dae230 commit 654f4f8
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 240 deletions.
2 changes: 1 addition & 1 deletion GGJ13/Drugs&Rock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,8 @@
isa = PBXGroup;
children = (
322FB31E18A6CB23004287FF /* GCHelper.h */,
322FB31F18A6CB23004287FF /* GCHelper.m */,
32425636168DDFBC0050EDD1 /* WHGameLayer.h */,
322FB31F18A6CB23004287FF /* GCHelper.m */,
32425637168DDFBC0050EDD1 /* WHGameLayer.mm */,
B541435116B3E601000E45B8 /* WHControlLayer.h */,
B541435216B3E601000E45B8 /* WHControlLayer.m */,
Expand Down
47 changes: 26 additions & 21 deletions GGJ13/GGJ13/WHControlLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,27 @@ - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

if (location.y < 150)
{
if (location.x < 80) {
[self.gameLayer touchBouton:0];
} else if (location.x < 160) {
[self.gameLayer touchBouton:1];
} else if (location.x < 240) {
[self.gameLayer touchBouton:2];
} else {
[self.gameLayer touchBouton:3];
}
if (!self.gameLayer.reverse) {
if (location.x < 80) {
[self.gameLayer touchBouton:0];
} else if (location.x < 160) {
[self.gameLayer touchBouton:1];
} else if (location.x < 240) {
[self.gameLayer touchBouton:2];
} else {
[self.gameLayer touchBouton:3];
}
} else {
if (location.x < 80) {
[self.gameLayer touchBouton:3];
} else if (location.x < 160) {
[self.gameLayer touchBouton:2];
} else if (location.x < 240) {
[self.gameLayer touchBouton:1];
} else {
[self.gameLayer touchBouton:0];
}
}
} else if (location.y > 300) {
NSLog(@"### Sauvegarde de la partition ###");
[self.gameLayer.recPartition saveDataForTrack:5];
Expand All @@ -52,18 +64,11 @@ - (void)ccTouchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint location = [touch locationInView: [touch view]];
location = [[CCDirector sharedDirector] convertToGL: location];

if (location.y < 150)
{
if (location.x < 80) {
[self.gameLayer restoreBouton:0];
} else if (location.x < 160) {
[self.gameLayer restoreBouton:1];
} else if (location.x < 240) {
[self.gameLayer restoreBouton:2];
} else {
[self.gameLayer restoreBouton:3];
}
}
[self.gameLayer restoreBouton:0];
[self.gameLayer restoreBouton:1];
[self.gameLayer restoreBouton:2];
[self.gameLayer restoreBouton:3];

}

}
Expand Down
1 change: 1 addition & 0 deletions GGJ13/GGJ13/WHGameLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@property (strong) NSMutableArray *boutons;
@property (weak) WHGameScene *gameScene;
@property (strong) dispatch_queue_t gcdQueue;
@property BOOL reverse;

-(void)touchBouton:(int)boutonNb;
-(void)newLevel:(int)gameBPM;
Expand Down
33 changes: 5 additions & 28 deletions GGJ13/GGJ13/WHGameLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ -(id) init
{
if( (self=[super init]) ) {
gcdQueue = dispatch_queue_create("org.sous-anneau.dnrqueue", NULL);
// // create and initialize a Label
// CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64];
//
// // ask director for the window size
// CGSize size = [[CCDirector sharedDirector] winSize];
//
// // position the label on the center of the screen
// label.position = ccp( size.width /2 , size.height/2 );
//
// // add the label as a child to this Layer
// [self addChild: label];

// init des variables
self.activeItems = [NSMutableArray new];
Expand All @@ -74,7 +63,8 @@ -(id) init

_currentMusicBPM = 0;
_elapsedTime = 0.0;
// [self startPartitionWithBPM:_currentMusicBPM];
_reverse = NO;


// éléments utiles uniquement pour enregistrer une partoche
#ifdef RECORDING_MODE
Expand Down Expand Up @@ -356,22 +346,7 @@ -(void)itemTapped:(WHItem *)item {

[self.gameScene updateJaugeWith:jaugeStatut];

if(item.type == ItemTypeNormal) {
[self.gameScene incrementScore:10];
}


if(item.type != ItemTypeNormal && !itemSent) {
// il faut appliquer l’item à notre propre face
[self.gameScene incrementBPM:[item effect]];

if (item.type == ItemTypeGHB) {
[self.gameScene displayMessage:3];
NSLog(@" todo effet ghb : score à zéro");
} else if (item.type == ItemTypeLSD) {
[self.gameScene displayMessage:2];
}
}
[self.gameScene mange:item withSent:itemSent];

[self.activeItems removeObject:item];
[self removeChild:item cleanup:YES];
Expand All @@ -381,6 +356,8 @@ -(void)itemTapped:(WHItem *)item {
}
}



-(void)itemMissed:(BOOL)bigMiss {
NSLog(@"%@ miss",bigMiss?@"Gros":@"Petit");
if (!_lastActionSuccess) {
Expand Down
5 changes: 5 additions & 0 deletions GGJ13/GGJ13/WHGameScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ typedef enum {
-(void) executeNewZique;
-(void) incrementScore:(int)i;
-(int) getTime;
-(void) setScore:(int)s;

-(void)mangeWithType:(int)m;
-(void)mange:(WHItem*)item withSent:(BOOL)itemSent;
-(void)mangeWithType:(int)m withSent:(BOOL)itemSent;

+(WHGameScene *) scene:(int)m;

Expand Down
Loading

0 comments on commit 654f4f8

Please sign in to comment.