Commits

Mateo Imbrišak committed 8ef85cf Merge

Merge

Comments (0)

Files changed (13)

 		<Option compiler="gcc" />
 		<Build>
 			<Target title="Debug">
-				<Option output="bin\Debug\Pucaljka" prefix_auto="1" extension_auto="1" />
-				<Option object_output="obj\Debug\" />
+				<Option output="bin/Debug/Pucaljka" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Debug/" />
 				<Option type="1" />
 				<Option compiler="gcc" />
 				<Compiler>
 				</Compiler>
 			</Target>
 			<Target title="Release">
-				<Option output="bin\Release\Pucaljka" prefix_auto="1" extension_auto="1" />
-				<Option object_output="obj\Release\" />
+				<Option output="bin/Release/Pucaljka" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Release/" />
 				<Option type="1" />
 				<Option compiler="gcc" />
 				<Compiler>
 		<Unit filename="pucaljka.cpp" />
 		<Unit filename="texture.cpp" />
 		<Unit filename="texture.h" />
+		<Unit filename="yellowenemyship.cpp" />
+		<Unit filename="yellowenemyship.h" />
 		<Extensions>
 			<code_completion />
 			<debugger />

Pucaljka.xcodeproj/project.pbxproj

 		7F9B660D1719986C004DC616 /* playership.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7F9B660A1719986C004DC616 /* playership.cpp */; };
 		7F9B66101719987B004DC616 /* enemyship01.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F9B660E1719987B004DC616 /* enemyship01.png */; };
 		7F9B66111719987B004DC616 /* playership.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F9B660F1719987B004DC616 /* playership.png */; };
+		7FFE2EB81722D53E0059ECD6 /* yellowenemyship.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FFE2EB61722D53E0059ECD6 /* yellowenemyship.cpp */; };
+		7FFE2EBA1722DE0B0059ECD6 /* enemyship02.png in Resources */ = {isa = PBXBuildFile; fileRef = 7FFE2EB91722DE0B0059ECD6 /* enemyship02.png */; };
 		AF1D1E8F1477E6D400C95550 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF1D1E8E1477E6D400C95550 /* Cocoa.framework */; };
 		AF1D1E991477E6D400C95550 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AF1D1E971477E6D400C95550 /* InfoPlist.strings */; };
 		AF1D1E9F1477E6D400C95550 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = AF1D1E9D1477E6D400C95550 /* Credits.rtf */; };
 		7F9B660B1719986C004DC616 /* playership.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = playership.h; sourceTree = SOURCE_ROOT; };
 		7F9B660E1719987B004DC616 /* enemyship01.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = enemyship01.png; sourceTree = "<group>"; };
 		7F9B660F1719987B004DC616 /* playership.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = playership.png; sourceTree = "<group>"; };
+		7FFE2EB61722D53E0059ECD6 /* yellowenemyship.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = yellowenemyship.cpp; sourceTree = SOURCE_ROOT; };
+		7FFE2EB71722D53E0059ECD6 /* yellowenemyship.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yellowenemyship.h; sourceTree = SOURCE_ROOT; };
+		7FFE2EB91722DE0B0059ECD6 /* enemyship02.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = enemyship02.png; sourceTree = "<group>"; };
 		AF1D1E8A1477E6D400C95550 /* Pucaljka.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pucaljka.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		AF1D1E8E1477E6D400C95550 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
 		AF1D1E911477E6D400C95550 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
 				7F9B660A1719986C004DC616 /* playership.cpp */,
 				7F225DD91710459C00D00DBE /* pucaljka.cpp */,
 				AF1D1EB31477E73E00C95550 /* texture.cpp */,
+				7FFE2EB61722D53E0059ECD6 /* yellowenemyship.cpp */,
 				7F225DE11710464100D00DBE /* button.h */,
 				7F9B66091719986B004DC616 /* enemyship.h */,
 				AF1D1EAC1477E73E00C95550 /* gamemode.h */,
 				7F9B660B1719986C004DC616 /* playership.h */,
 				AF1D1EB11477E73E00C95550 /* SDLMain.h */,
 				AF1D1EB41477E73E00C95550 /* texture.h */,
+				7FFE2EB71722D53E0059ECD6 /* yellowenemyship.h */,
 				AF1D1EB21477E73E00C95550 /* SDLMain.m */,
 				7F225DD71710459C00D00DBE /* newgame.png */,
 				7F225DD81710459C00D00DBE /* options.png */,
 			isa = PBXGroup;
 			children = (
 				7F9B660E1719987B004DC616 /* enemyship01.png */,
+				7FFE2EB91722DE0B0059ECD6 /* enemyship02.png */,
 				7F9B660F1719987B004DC616 /* playership.png */,
 				7F225DE41710465E00D00DBE /* background.png */,
 				7F225DE51710465E00D00DBE /* credits.png */,
 				7F225DE91710465E00D00DBE /* exit.png in Resources */,
 				7F9B66101719987B004DC616 /* enemyship01.png in Resources */,
 				7F9B66111719987B004DC616 /* playership.png in Resources */,
+				7FFE2EBA1722DE0B0059ECD6 /* enemyship02.png in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				7F225DF21710484000D00DBE /* layer.cpp in Sources */,
 				7F9B660C1719986C004DC616 /* enemyship.cpp in Sources */,
 				7F9B660D1719986C004DC616 /* playership.cpp in Sources */,
+				7FFE2EB81722D53E0059ECD6 /* yellowenemyship.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 #include "EnemyShip.h"
 #include "texture.h"
-
+#include <math.h>
 
 EnemyShip::EnemyShip(const std::string& textureFile,
                const int argX,
-               const int argY) : texture(new Texture(textureFile)), x(argX), y(argY)
+               const int argY) : texture(new Texture(textureFile)), x(argX), y(argY), angle(0)
 {
 }
 
     glPushMatrix();
     glTranslatef(this->x, this->y, 0);
     glScalef(64, 64, 0);
-    glRotatef(90, 0, 0, 1);
-    //glRotatef(angle, 0, 0, 1);
+    glRotatef(-90, 0, 0, 1);
+    glRotatef(this->angle * 180 / M_PI, 0, 0, 1);
     glBegin(GL_TRIANGLES);
     
     
 }
 
 void
-EnemyShip::updateSelf(const float timeDelta)
+EnemyShip::updateSelf(const double timeDelta)
 {
 }
 
     virtual void paintSelf(void);
 
 
-    virtual void updateSelf(const float timeDelta);
+    virtual void updateSelf(const double timeDelta);
 
     private:
     Texture*texture;
+    
+    protected:
     float x,y;
+    float angle;
 };
 
 
 #include "layer.h"
 #include "enemyship.h"
 #include "playership.h"
+#include "yellowenemyship.h"
 
 extern bool gRunning;
 extern SDL_Surface * gScreen;
 GM_Level::GM_Level() : playership(new PlayerShip("playership.png", 150, 200))
 {
     EnemyShip *enemyShip(new EnemyShip("enemyship01.png", 600, 400));
+    EnemyShip *blueenemyShip(new EnemyShip("enemyship02.png", 800, 400));
     this->enemyShips.push_back(enemyShip);
+    this->enemyShips.push_back(blueenemyShip);
+    
+    
+    for(int i = 0; i < 50; i++)
+    {
+        YellowEnemyShip *yellowEnemyShip(new YellowEnemyShip(320 + i * 60, 240));
+        this->enemyShips.push_back(yellowEnemyShip);
+    }
+    
+    for(int i = 0; i < 50; i++)
+    {
+        YellowEnemyShip *yellowEnemyShip(new YellowEnemyShip(320 + i * 60, -240));
+        this->enemyShips.push_back(yellowEnemyShip);
+    }
+    
+    
+    for(int i = 0; i < 50; i++)
+    {
+        YellowEnemyShip *yellowEnemyShip(new YellowEnemyShip(320 + i * 60, 120));
+        this->enemyShips.push_back(yellowEnemyShip);
+    }
+    
+    for(int i = 0; i < 50; i++)
+    {
+        YellowEnemyShip *yellowEnemyShip(new YellowEnemyShip(320 + i * 60, -120));
+        this->enemyShips.push_back(yellowEnemyShip);
+    }
 }
 
 void
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
-    gluOrtho2D(0, gScreen->w, gScreen->h, 0);
+    gluOrtho2D(-320, 320, 240, -240);
 
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     Layer *layer(new Layer("background.png", gScreen->w / 2,gScreen->h / 2));
     this->layer.push_back(layer);
 
-    Button *newgameButton(new NewGameButton("newgame.png", 130, 50));
+    Button *newgameButton(new NewGameButton("newgame.png", 130, 100));
     this->buttons.push_back(newgameButton);
 
-    Button *optionsButton(new OptionsButton("options.png", 130, 175));
+    Button *optionsButton(new OptionsButton("options.png", 130, 160));
     this->buttons.push_back(optionsButton);
 
-    Button *creditsButton(new CreditsButton("credits.png", 130, 300));
+    Button *creditsButton(new CreditsButton("credits.png", 130, 220));
     this->buttons.push_back(creditsButton);
 
-    Button *exitButton(new ExitButton("exit.png", 130, 450));
+    Button *exitButton(new ExitButton("exit.png", 130, 335));
     this->buttons.push_back(exitButton);
 
 
 #include "gm_level.h"
 
 static const double playerShipAngleV = 180;
+static const double playerShipYV = 150;
+
 extern GameMode* gGame;
 
 PlayerShip::PlayerShip(const std::string& textureFile,
                        const int argX,
-                       const int argY) : texture(new Texture(textureFile)), x(argX), y(argY), angle(0), angleV(0)
+                       const int argY) : texture(new Texture(textureFile)), x(argX), y(argY), angle(0), angleV(0), yv(0)
 {
 
 }
 PlayerShip::updateSelf(double timeDelta)
 {
     angle += angleV * timeDelta;
+    y += yv * timeDelta;
 }
 
 void
         break;
 
         case SDLK_UP:
-        y = y - 5;
+        yv = -playerShipYV;
         break;
 
         case SDLK_DOWN:
-        y = y + 5;
+        yv =  playerShipYV;
         break;
 
         case SDLK_SPACE:
             angleV = 0;
             break;
 
+        case SDLK_UP:
+            yv = 0;
+            break;
+        case SDLK_DOWN:
+            yv = 0;
+			break;
         default:
             break;
     }
 
-
 }
 
 void
     float x, y;
     double angle;
     double angleV;
+    double yv;
 };
 #endif
 
Add a comment to this file

playership.png

Old
Old image
New
New image
         OldTime = NewTime;
         float dt = differenceInMiliseconds / 1000.0;
 
+        if(dt > 0.2)
+            dt = 0.2;
+        
         gGame->paintSelf();
         gGame->updateSelf(dt);
 

yellowenemyship.cpp

+#include <math.h>
+#include "yellowenemyship.h"
+
+YellowEnemyShip::YellowEnemyShip(const double x,
+                                 const double y) : EnemyShip("enemyship02.png", x, y), defaultY(y)
+{
+}
+
+YellowEnemyShip::~YellowEnemyShip()
+{
+}
+
+void
+YellowEnemyShip::updateSelf(const double timeDelta)
+{
+    EnemyShip::updateSelf(timeDelta);
+    
+    this->x -= 200 * timeDelta;
+    
+    double defaultYPositive = fabs(this->defaultY);
+    if(this->defaultY > 0)
+    {
+        this->y = -((log(x + 320) / 6.4) * defaultYPositive*2 - defaultYPositive);
+    }
+    else
+    {
+        this->y = (log(x + 320) / 6.4) * defaultYPositive*2 - defaultYPositive;
+    }
+/*
+    this->angle = atan2((0.3125 * 2 * defaultYPositive) / (this->x * 320.), this->x);
+*/
+}
+

yellowenemyship.h

+#ifndef PUCALJKA_YELLOWENEMYSHIP_H
+#define PUCALJKA_YELLOWENEMYSHIP_H
+
+#include "enemyship.h"
+
+class YellowEnemyShip : public EnemyShip
+{
+    public:
+    YellowEnemyShip(const double x,
+                    const double y);
+    ~YellowEnemyShip();
+    
+    void updateSelf(const double timeDelta);
+    
+    private:
+    double defaultY;
+    
+};
+
+#endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.