Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Final_Project/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
47 changes: 47 additions & 0 deletions Final_Project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
68 changes: 68 additions & 0 deletions Final_Project/Enemy.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class Enemy {
PImage image, imagered;
PImage blast;
PVector x, y, picvel;
PVector x2, y2, picvel2;
PVector x3, y3, picvel3;
Enemy() {
image = loadImage("enemy.png");
imagered = loadImage("enemyred");
blast = loadImage("blast.png");
x = new PVector(random(30, width-30), 0);
x2 = new PVector(random(30, width-30), 0);
x3 = new PVector(random(30, width-30), 0);
y = new PVector(0, height/2);
picvel = new PVector(-random(2, 3), 0);
picvel2 = new PVector(random(2, 3), 0);
picvel3 = new PVector(random(2, 3), 0);
y2 = new PVector(0, height/2-200);
y3 = new PVector(0, height/2+200);
}

void displaystg1lvl1() {
x.add(picvel);
x2.add(picvel2);
x3.add(picvel3);
image(image, x.x, y.y); //flip image
image(image, x2.x, y2.y);
image(image, x3.x, y3.y);
if (x.x+40>= width) {
picvel.x*=-1;
}
if (x.x-40<=0) {
picvel.x*=-1;
}
if (x2.x+40>= width) {
picvel2.x*=-1;
}
if (x2.x-40<=0) {
picvel2.x*=-1;
}
if (x3.x+40>= width) {
picvel3.x*=-1;
}
if (x3.x-40<=0) {
picvel3.x*=-1;
}
}

void bossdisplay() {
}

boolean isInContactEnemy(Sprite player) { //find out if there is an easier way to make each individual enemy and fix contact and if you can only have one contact (maybe array)
if ( player.per.dist(x) < 100) {
println("Contact!!!!!!!");
return true;
} else {
println("NO Contact");
return false;
}
}
void enemydissapear() {
//if ("enemydissapear"){
//level.xp+=10;
// }
}
void survival() {
}
}
143 changes: 143 additions & 0 deletions Final_Project/Final_Project.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
Sprite player;
Map map;
Save save;
Enemy enemy;
Levels level;
Over gameover;
float l = 0;
float r = 0;
float down = 0;
float up = 0;
float grav = .5;
float floor = 700;
float speedStat = 2;
float stage = 1;
void setup() {
size(1000, 800);
enemy = new Enemy();
player = new Sprite();
map = new Map();
save = new Save();
level = new Levels();
gameover = new Over();
}

void draw() {
background(100);
//player.display();
map.display();
save.savegame();
enemy.displaystg1lvl1();
enemy.isInContactEnemy(player);
level.display();
player.health();
level.levelup();
enemy.enemydissapear();
player.loselife();
if (player.lives == 0) {
gameover.display();
}
if (save.saving == 1) {
if (mouseX > save.x && mouseY > save.y && mouseX < save.x+save.r && mouseY < save.y+save.h) {
save.mouseReleased();
}
}
if (player.per.y >= map.y-map.h && player.per.x < map.w) {
player.vel.y = 0;
}
if (player.per.x-30>= width) {
background(0, 0, 255);
save.savegame();
player.per.x = 0;
}
if (player.per.x-30<= 0) {
player.per.x = 35;
}
player.vel.x = player.sp * (l + r);
player.per.add(player.vel);
if (player.per.y < floor) {
player.vel.y += grav;
} else {
player.vel.y = 0;
}
if (player.per.y >= floor && up != 0) {
player.vel.y = -player.ysp;
}
player.frameTime += .25;
if (player.frameTime >= 8) {
player.frameTime = 1;
}
player.frameColumn = (int)player.frameTime;

if (player.vel.x == 0 && player.vel.y == 0) {
player.frameColumn = 0;
}

if (l != 0) {
player.frameRow = 0;
}
if (r != 0) {
player.frameRow = 1;
}
if (level.l == 1) {
if (player.sp > 4 || player.sp<1) {
player.sp = 2;
}
}
if (level.l == 2) {
speedStat = 4;
if (player.sp > 8 || player.sp<1) {
player.sp = 2; //add other levels to game
}
}
pushMatrix();
translate(player.per.x, player.per.y);
imageMode(CENTER);

PImage frameImage = getSubImage(player.image, player.frameRow, player.frameColumn, 100, 105);
PImage frameImagered = getSubImage(player.imagered, player.frameRow, player.frameColumn, 100, 105);
// Draw this image instead of player.image
if (stage ==1){
image(frameImage, 0, 0);
}
if (stage == 2){
image(frameImagered, 0, 0);
}
popMatrix();
}
// Our function to return a new smaller crop from the spritesheet.
PImage getSubImage(PImage image, int row, int column, int frameWidth, int frameHeight) {
return image.get(column * frameWidth, row * frameHeight, frameWidth, frameHeight);

}

void keyPressed() {
if (keyCode == RIGHT) {
r = 1;
}
if (keyCode == LEFT) {
l = -1;
}
if (keyCode == UP) {
up = -1;
}
if (key == 'z') {
player.sp += speedStat;
}
}

void keyReleased() {
if (keyCode == RIGHT) {
r = 0;
player.frameTime = 1;
}
if (keyCode == LEFT) {
l = 0;
}
if (keyCode == UP) {
up = 0;
}
if (key == 'z') {
player.sp -= speedStat;
}
}
22 changes: 22 additions & 0 deletions Final_Project/Game_Map.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Map {
float x=0;
float y=height/2+200;
float w=600;
float h=50;
float x2=0;
float y2=height/2-200;
float w2=600;
float h2=50;
float x3=400;
float y3=height/2;
float w3=600;
float h3=50;
void display() {
stroke(0);
strokeWeight(12);
fill(255);
rect(x2, y2, w2, h2);
rect(x, y, w, h);
rect(x3, y3, w3, h3);
}
}
6 changes: 6 additions & 0 deletions Final_Project/Game_Over.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Over{
void display(){
background(0);
text("Game Over",width/2,height/2);
}
}
Loading