Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Aburto committed Sep 30, 2009
0 parents commit beaeeb2
Show file tree
Hide file tree
Showing 175 changed files with 31,200 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -crlf -diff -merge
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# xcode noise
build/*
*.pbxuser
*.mode1v3

# old skool
.svn

# osx noise
.DS_Store
profile
35 changes: 35 additions & 0 deletions Classes/Block.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Tetromino.h
// Tetris
//
// Created by Joshua Aburto on 9/26/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "cocos2d.h"


@interface Block : Sprite {
int boardX, boardY;
BOOL stuck;
BOOL disappearing;


}

@property int boardX;
@property int boardY;
@property BOOL stuck;
@property BOOL disappearing;

+ (Block *)newBlock:(int)blockType;
- (void)moveUp;
- (void)moveDown;
- (void)moveLeft;
- (void)moveRight;

@end

#define COMPUTE_X(x) (abs(x) * 24)
#define COMPUTE_Y(y) (456 - (abs(y) * 24))
#define COMPUTE_X_Y(x,y) ccp( COMPUTE_X(x), COMPUTE_Y(y))
111 changes: 111 additions & 0 deletions Classes/Block.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//
// Tetromino.m
// Tetris
//
// Created by Joshua Aburto on 9/26/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "Block.h"

@interface Block (private)

- (void)initializeDefaults;
- (void)redrawPositionOnBoard;

@end

@implementation Block

@synthesize boardX;
@synthesize boardY;
@synthesize stuck;
@synthesize disappearing;

+ (Block *)newBlock:(int)blockType
{
NSString *filename = nil, *color = nil;
Block *temp = nil;

switch (blockType) {
case 0:
color = @"red";
break;
case 1:
color = @"blue";
break;
case 2:
color = @"orange";
break;
case 3:
color = @"yellow";
break;
case 4:
color = @"magenta";
break;
case 5:
color = @"cyan";
break;
case 6:
color = @"green";
break;
default:
break;
}

if (color) {
filename = [[NSString alloc] initWithFormat:@"%@.png", color];
temp = [[self spriteWithFile:filename] retain];
[filename release];

[temp initializeDefaults];

}
return temp;

}


- (void)initializeDefaults
{
[self setAnchorPoint: ccp(0,0)];
[self setPosition: ccp(0,0)];
[self setOpacity:255];
[self setStuck:NO];
[self setDisappearing:NO];
[self setBoardX:0];
[self setBoardY:0];
}

- (void)redrawPositionOnBoard
{
[self setPosition: COMPUTE_X_Y(boardX, boardY)];
}

- (void)moveUp
{
boardY -= 1;
[self redrawPositionOnBoard];
}

- (void)moveDown
{
boardY += 1;
[self redrawPositionOnBoard];
}

- (void)moveLeft
{
boardX -= 1;
[self redrawPositionOnBoard];
}

- (void)moveRight
{
boardX += 1;
[self redrawPositionOnBoard];
}



@end
38 changes: 38 additions & 0 deletions Classes/GameLogicLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// GameLogicLayer.h
// Tetris
//
// Created by Joshua Aburto on 9/26/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "Tetromino.h"
#import "Block.h"
#define kLastColumn 9
#define kLastRow 19

@interface GameLogicLayer : Layer {
enum touchTypes {
kNone,
kDropBlocks,
kBlockFlip,
kMoveLeft,
kMoveRight
} touchType;

Block *board[kLastColumn + 1][kLastRow + 1];
Tetromino *userTetromino;
int frameCount;
int moveCycleRatio;
int difficulty;
int score;
Label *scoreLabel;
Label *difficultyLabel;


}


- (void)updateBoard:(ccTime)dt;

@end
Loading

0 comments on commit beaeeb2

Please sign in to comment.