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 */
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 */
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;
#include <stdio.h>
#include <time.h>
+#include <math.h>
#include "SDL2/SDL.h"
#include "SDL2_image/SDL_image.h"
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) {
// 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;
// Event Loop.
while (!done) {
startFrame = SDL_GetTicks();
+ dt = startFrame - lastTime;
+ lastTime = startFrame;
+
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
}
}
+ update(dt);
render(renderer);
endFrame = SDL_GetTicks();
SDL_Delay(delay);
}
- SDL_Quit();
+ close();
return 0;
}