Commits

Ivan Vučica committed 7ae1cf1

Yellow enemy ship code. -320 -> 320, -240 -> 240. Angle support in enemy ship.

Comments (0)

Files changed (6)

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;
     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();
+#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);
+*/
+}
+
+#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