]> git.r.bdr.sh - rbdr/super-polarity/commitdiff
Rotation!
authorBen Beltran <redacted>
Wed, 14 Aug 2013 03:01:37 +0000 (22:01 -0500)
committerBen Beltran <redacted>
Wed, 14 Aug 2013 03:01:37 +0000 (22:01 -0500)
Super Polarity.xcodeproj/project.pbxproj
Super Polarity.xcodeproj/project.xcworkspace/xcuserdata/benbeltran.xcuserdatad/UserInterfaceState.xcuserstate
src/main.c

index 5b989b0c11b376d57121e40623e4691bd08bbc1f..364ccf7ad8f30821dcb0295ea45285ca1d15f566 100644 (file)
                8E9D792817BA690700C76DC9 /* SDL2_net.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E9D792317BA690700C76DC9 /* SDL2_net.framework */; };
                8E9D792917BA690700C76DC9 /* SDL2_ttf.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E9D792417BA690700C76DC9 /* SDL2_ttf.framework */; };
                8E9D792A17BA690700C76DC9 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E9D792517BA690700C76DC9 /* SDL2.framework */; };
+               8EC3B7BA17BB185D00D3BDD0 /* ben.png in Copy Static Images */ = {isa = PBXBuildFile; fileRef = 8EC3B7B917BB185700D3BDD0 /* ben.png */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
-               8E9D78E717BA63F400C76DC9 /* CopyFiles */ = {
+               8E9D78E717BA63F400C76DC9 /* Copy Static Images */ = {
                        isa = PBXCopyFilesBuildPhase;
-                       buildActionMask = 2147483647;
-                       dstPath = /usr/share/man/man1/;
-                       dstSubfolderSpec = 0;
+                       buildActionMask = 12;
+                       dstPath = data/img/static;
+                       dstSubfolderSpec = 16;
                        files = (
+                               8EC3B7BA17BB185D00D3BDD0 /* ben.png in Copy Static Images */,
                        );
-                       runOnlyForDeploymentPostprocessing = 1;
+                       name = "Copy Static Images";
+                       runOnlyForDeploymentPostprocessing = 0;
                };
 /* End PBXCopyFilesBuildPhase section */
 
@@ -36,6 +39,7 @@
                8E9D792317BA690700C76DC9 /* SDL2_net.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2_net.framework; path = vendor/frameworks/SDL2_net.framework; sourceTree = "<group>"; };
                8E9D792417BA690700C76DC9 /* SDL2_ttf.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2_ttf.framework; path = vendor/frameworks/SDL2_ttf.framework; sourceTree = "<group>"; };
                8E9D792517BA690700C76DC9 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = vendor/frameworks/SDL2.framework; sourceTree = "<group>"; };
+               8EC3B7B917BB185700D3BDD0 /* ben.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ben.png; path = data/img/static/ben.png; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -57,6 +61,7 @@
                8E9D78E017BA63F400C76DC9 = {
                        isa = PBXGroup;
                        children = (
+                               8EC3B7B617BB183500D3BDD0 /* data */,
                                8E9D792117BA690700C76DC9 /* SDL2_image.framework */,
                                8E9D792217BA690700C76DC9 /* SDL2_mixer.framework */,
                                8E9D792317BA690700C76DC9 /* SDL2_net.framework */,
                        path = src;
                        sourceTree = "<group>";
                };
+               8EC3B7B617BB183500D3BDD0 /* data */ = {
+                       isa = PBXGroup;
+                       children = (
+                               8EC3B7B717BB183900D3BDD0 /* img */,
+                       );
+                       name = data;
+                       sourceTree = "<group>";
+               };
+               8EC3B7B717BB183900D3BDD0 /* img */ = {
+                       isa = PBXGroup;
+                       children = (
+                               8EC3B7B817BB183E00D3BDD0 /* static */,
+                       );
+                       name = img;
+                       sourceTree = "<group>";
+               };
+               8EC3B7B817BB183E00D3BDD0 /* static */ = {
+                       isa = PBXGroup;
+                       children = (
+                               8EC3B7B917BB185700D3BDD0 /* ben.png */,
+                       );
+                       name = static;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
                        buildPhases = (
                                8E9D78E517BA63F400C76DC9 /* Sources */,
                                8E9D78E617BA63F400C76DC9 /* Frameworks */,
-                               8E9D78E717BA63F400C76DC9 /* CopyFiles */,
+                               8E9D78E717BA63F400C76DC9 /* Copy Static Images */,
                        );
                        buildRules = (
                        );
                8E9D78F317BA63F400C76DC9 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CLANG_ENABLE_OBJC_ARC = NO;
                                FRAMEWORK_SEARCH_PATHS = (
                                        "$(inherited)",
                                        "\"$(SRCROOT)/vendor/frameworks\"",
                                );
+                               MACH_O_TYPE = mh_execute;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = Debug;
                8E9D78F417BA63F400C76DC9 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               CLANG_ENABLE_OBJC_ARC = NO;
                                FRAMEWORK_SEARCH_PATHS = (
                                        "$(inherited)",
                                        "\"$(SRCROOT)/vendor/frameworks\"",
                                );
+                               MACH_O_TYPE = mh_execute;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                        };
                        name = Release;
index fe3788121143f6adc58b56b869f4d306a46e550d..11dbff62223546b197386a0bc14a202848d0d05b 100644 (file)
Binary files a/Super Polarity.xcodeproj/project.xcworkspace/xcuserdata/benbeltran.xcuserdatad/UserInterfaceState.xcuserstate and b/Super Polarity.xcodeproj/project.xcworkspace/xcuserdata/benbeltran.xcuserdatad/UserInterfaceState.xcuserstate differ
index 602dff33c942b2a89952eb13ee5890e8413c8458..b51a79d2b4066289518b36c00e51bc6a6f059c75 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <stdio.h>
 #include <time.h>
+#include <math.h>
 
 #include "SDL2/SDL.h"
 #include "SDL2_image/SDL_image.h"
@@ -19,7 +20,9 @@
 
 SDL_Window *window;
 SDL_Renderer *renderer;
-SDL_Surface *benHead;
+SDL_Texture *benHead;
+SDL_Rect benRect;
+double angle = 0;
 
 void init () {
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@@ -35,25 +38,51 @@ void init () {
     // Set linear quality for scaling, and the "logical" window size.
     SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
     SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);
-    
+}
+
+void close () {
+    SDL_DestroyTexture(benHead);
+    SDL_DestroyRenderer(renderer);
+    SDL_DestroyWindow(window);
+    SDL_Quit();
+}
+
+void loadAssets() {
     // Load the surface.
-    // benHead = IMG_Load("data/img/static/ben.png");
+    SDL_Surface *benSurface;
+    benSurface = IMG_Load("data/img/static/ben.png");
+    benHead = SDL_CreateTextureFromSurface(renderer, benSurface);
+    benRect.x = 230;
+    benRect.y = 150;
+    benRect.w = 180;
+    benRect.h = 180;
+    SDL_FreeSurface(benSurface);
 }
 
 void render (SDL_Renderer *renderer) {
     SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
     SDL_RenderClear(renderer);
+    SDL_RenderCopyEx(renderer, benHead, NULL, &benRect, angle, NULL, SDL_FLIP_NONE);
     SDL_RenderPresent(renderer);
 }
 
-int mainC(int argc, const char * argv[])
+void update (dt) {
+    angle = (Uint32)(angle + dt / 5) % 360;
+}
+
+int main(int argc, const char * argv[])
 {
     
     // SDL Initialization. TODO: Should have an initializer.
-    Uint32 startFrame;
-    Uint32 endFrame;
+    Uint32 startFrame = 0;
+    Uint32 endFrame = 0;
+    Uint32 lastTime = 0;
+    Uint32 dt;
     Uint32 delay;
     int done;
+    
+    init();
+    loadAssets();
    
     
     done = 0;
@@ -61,6 +90,9 @@ int mainC(int argc, const char * argv[])
     // Event Loop.
     while (!done) {
         startFrame = SDL_GetTicks();
+        dt = startFrame - lastTime;
+        lastTime = startFrame;
+        
         SDL_Event event;
         while (SDL_PollEvent(&event)) {
             if (event.type == SDL_QUIT) {
@@ -68,6 +100,7 @@ int mainC(int argc, const char * argv[])
             }
         }
         
+        update(dt);
         render(renderer);
         
         endFrame = SDL_GetTicks();
@@ -80,7 +113,7 @@ int mainC(int argc, const char * argv[])
         SDL_Delay(delay);
     }
     
-    SDL_Quit();
+    close();
 
     return 0;
 }