diff options
| author | Ben Beltran <ben@nsovocal.com> | 2014-02-03 09:55:31 -0600 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2014-02-03 09:55:31 -0600 |
| commit | 0cafec445af0a97d96feb1a1daefa1486142c73f (patch) | |
| tree | 818df31eec1895518ad805219b79bc63f9f616aa /src | |
| parent | 830829dec0596760d0cba38d959ab2646112f61b (diff) | |
Removes old stuff, adds mac proj
Diffstat (limited to 'src')
| -rw-r--r-- | src/Super_Polarity.1 | 79 | ||||
| -rw-r--r-- | src/actor.c | 44 | ||||
| -rw-r--r-- | src/actor.h | 30 | ||||
| -rw-r--r-- | src/actor_manager.c | 57 | ||||
| -rw-r--r-- | src/actor_manager.h | 32 | ||||
| -rw-r--r-- | src/main.c | 150 |
6 files changed, 0 insertions, 392 deletions
diff --git a/src/Super_Polarity.1 b/src/Super_Polarity.1 deleted file mode 100644 index 0fd5f7c..0000000 --- a/src/Super_Polarity.1 +++ /dev/null @@ -1,79 +0,0 @@ -.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
-.\"See Also:
-.\"man mdoc.samples for a complete listing of options
-.\"man mdoc for the short list of editing options
-.\"/usr/share/misc/mdoc.template
-.Dd 8/13/13 \" DATE
-.Dt Super Polarity 1 \" Program name and manual section number
-.Os Darwin
-.Sh NAME \" Section Header - required - don't modify
-.Nm Super Polarity,
-.\" The following lines are read in generating the apropos(man -k) database. Use only key
-.\" words here as the database is built based on the words here and in the .ND line.
-.Nm Other_name_for_same_program(),
-.Nm Yet another name for the same program.
-.\" Use .Nm macro to designate other names for the documented program.
-.Nd This line parsed for whatis database.
-.Sh SYNOPSIS \" Section Header - required - don't modify
-.Nm
-.Op Fl abcd \" [-abcd]
-.Op Fl a Ar path \" [-a path]
-.Op Ar file \" [file]
-.Op Ar \" [file ...]
-.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
-arg2 ... \" Arguments
-.Sh DESCRIPTION \" Section Header - required - don't modify
-Use the .Nm macro to refer to your program throughout the man page like such:
-.Nm
-Underlining is accomplished with the .Ar macro like this:
-.Ar underlined text .
-.Pp \" Inserts a space
-A list of items with descriptions:
-.Bl -tag -width -indent \" Begins a tagged list
-.It item a \" Each item preceded by .It macro
-Description of item a
-.It item b
-Description of item b
-.El \" Ends the list
-.Pp
-A list of flags and their descriptions:
-.Bl -tag -width -indent \" Differs from above in tag removed
-.It Fl a \"-a flag as a list item
-Description of -a flag
-.It Fl b
-Description of -b flag
-.El \" Ends the list
-.Pp
-.\" .Sh ENVIRONMENT \" May not be needed
-.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
-.\" .It Ev ENV_VAR_1
-.\" Description of ENV_VAR_1
-.\" .It Ev ENV_VAR_2
-.\" Description of ENV_VAR_2
-.\" .El
-.Sh FILES \" File used or created by the topic of the man page
-.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
-.It Pa /usr/share/file_name
-FILE_1 description
-.It Pa /Users/joeuser/Library/really_long_file_name
-FILE_2 description
-.El \" Ends the list
-.\" .Sh DIAGNOSTICS \" May not be needed
-.\" .Bl -diag
-.\" .It Diagnostic Tag
-.\" Diagnostic informtion here.
-.\" .It Diagnostic Tag
-.\" Diagnostic informtion here.
-.\" .El
-.Sh SEE ALSO
-.\" List links in ascending order by section, alphabetically within a section.
-.\" Please do not reference files that do not exist without filing a bug report
-.Xr a 1 ,
-.Xr b 1 ,
-.Xr c 1 ,
-.Xr a 2 ,
-.Xr b 2 ,
-.Xr a 3 ,
-.Xr b 3
-.\" .Sh BUGS \" Document known, unremedied bugs
-.\" .Sh HISTORY \" Document history if command behaves in a unique manner
\ No newline at end of file diff --git a/src/actor.c b/src/actor.c deleted file mode 100644 index 32028a1..0000000 --- a/src/actor.c +++ /dev/null @@ -1,44 +0,0 @@ -// -// actor.c -// Super Polarity -// -// Created by Ruben Beltran del Rio on 8/14/13. -// Copyright (c) 2013 Abuguet. All rights reserved. -// - -#include <stdio.h> -#include "actor.h" - -SDL_Renderer *renderer; - -void actorUpdate(Actor *this, Uint32 dt) { - this->textureBox.x = this->pos.x; - this->textureBox.y = this->pos.y; - this->angle = (Uint32)(this->angle + dt / 5) % 360; -} - -void actorDraw(Actor *this) { - SDL_RenderCopyEx(renderer, this->texture, NULL, &this->textureBox, this->angle, NULL, SDL_FLIP_NONE); -} - -// This constructor is pretty much dumb. So, don't take it as anything final. -Actor* createActor () { - Actor *actor = malloc(sizeof(Actor*)); - actor->pos.x = 0; - actor->pos.y = 0; - actor->update = actorUpdate; - actor->draw = actorDraw; - actor->angle = 0.0; - - // Load the surface. - SDL_Surface *benSurface; - benSurface = IMG_Load("data/img/static/ben.png"); - actor->texture = SDL_CreateTextureFromSurface(renderer, benSurface); - actor->textureBox.x = 230; - actor->textureBox.y = 150; - actor->textureBox.w = 180; - actor->textureBox.h = 180; - SDL_FreeSurface(benSurface); - - return actor; -}
\ No newline at end of file diff --git a/src/actor.h b/src/actor.h deleted file mode 100644 index 8bb7a88..0000000 --- a/src/actor.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// actor.h -// Super Polarity -// -// Created by Ruben Beltran del Rio on 8/14/13. -// Copyright (c) 2013 Abuguet. All rights reserved. -// - -#ifndef Super_Polarity_actor_h -#define Super_Polarity_actor_h - -#include "SDL2/SDL.h" -#include "SDL2_image/SDL_image.h" - -typedef struct actor_struct Actor; - -typedef struct actor_struct { - SDL_Point pos; - SDL_Point vel; - SDL_Point acc; - SDL_Rect textureBox; - SDL_Texture *texture; - double angle; - void (*update)(Actor *, Uint32); - void (*draw)(Actor *); -} Actor; - -Actor* createActor(); - -#endif diff --git a/src/actor_manager.c b/src/actor_manager.c deleted file mode 100644 index c9303d2..0000000 --- a/src/actor_manager.c +++ /dev/null @@ -1,57 +0,0 @@ -// -// actor_manager.c -// Super Polarity -// -// Created by Ruben Beltran del Rio on 8/14/13. -// Copyright (c) 2013 Abuguet. All rights reserved. -// - -#include <stdio.h> -#include "actor_manager.h" - -void actorManagerUpdate(ActorManager *this, Uint32 dt) { - ActorNode *head = this->actors; - - while (head != NULL) { - head->val->update(head->val, dt); - head = head->next; - } -} - -void actorManagerDraw(ActorManager *this) { - ActorNode *head = this->actors; - - while (head != NULL) { - head->val->draw(head->val); - head = head->next; - } -} - -void actorManagerAddActor(ActorManager *this, Actor *actor) { - ActorNode *actorNode = malloc(sizeof(ActorNode*)); - ActorNode **head = &this->actors; - ActorNode *temp; - actorNode->val = actor; - actorNode->next = NULL; - - if (*head == NULL) { - *head = actorNode; - } else { - temp = *head; - - while (temp->next != NULL) { - temp = temp->next; - } - temp->next = actorNode; - } -} - -ActorManager* createActorManager () { - ActorManager *actorManager = malloc(sizeof(ActorManager*)); - actorManager->actors = NULL; - actorManager->update = actorManagerUpdate; - actorManager->draw = actorManagerDraw; - actorManager->addActor = actorManagerAddActor; - - return actorManager; -}
\ No newline at end of file diff --git a/src/actor_manager.h b/src/actor_manager.h deleted file mode 100644 index 900c57c..0000000 --- a/src/actor_manager.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// actor_manager.h -// Super Polarity -// -// Created by Ruben Beltran del Rio on 8/14/13. -// Copyright (c) 2013 Abuguet. All rights reserved. -// - -#ifndef Super_Polarity_actor_manager_h -#define Super_Polarity_actor_manager_h - -#include "SDL2/SDL.h" -#include "actor.h" - -typedef struct actor_manager ActorManager; -typedef struct actor_node ActorNode; - -typedef struct actor_manager { - ActorNode *actors; - void (*update)(ActorManager *, Uint32); - void (*draw)(ActorManager *); - void (*addActor)(ActorManager *, Actor *); -} ActorManager; - -typedef struct actor_node { - Actor *val; - ActorNode *next; -} ActorNode; - -ActorManager* createActorManager(); - -#endif diff --git a/src/main.c b/src/main.c deleted file mode 100644 index ae73a22..0000000 --- a/src/main.c +++ /dev/null @@ -1,150 +0,0 @@ -// -// main.c -// Super Polarity -// -// Created by Ruben Beltran del Rio on 8/13/13. -// Copyright (c) 2013 Abuguet. All rights reserved. -// - -#include <stdio.h> -#include <time.h> -#include <math.h> - -#include "SDL2/SDL.h" -#include "SDL2_image/SDL_image.h" - -#include "actor.h" -#include "actor_manager.h" - -// TODO: Move these guys to a config header file -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 -#define FPS 30 - -SDL_Window *window; -SDL_Renderer *renderer; -SDL_Texture *benHead; -SDL_Rect benRect; -bool focus; - -ActorManager *actorManager; - -void init () { - if (SDL_Init(SDL_INIT_VIDEO) < 0) { - printf("Could not initialize SDL"); - exit(1); - } - - // Load the window and renderer - window = SDL_CreateWindow("Super Polarity", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 0, 0, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN_DESKTOP); - - renderer = SDL_CreateRenderer(window, -1, 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 initActorManager () { - Actor *actor; - Actor *otherActor; - - //test the Actor Manager. - actorManager = createActorManager(); - - actor = createActor(); - actor->pos.x = 55; - actor->pos.y = 24; - actorManager->addActor(actorManager, actor); - - otherActor = createActor(); - otherActor->pos.x=100; - otherActor->pos.y=100; - actorManager->addActor(actorManager, otherActor); - -} - -void loadAssets() { - initActorManager(); -} - -void draw (SDL_Renderer *renderer) { - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); - SDL_RenderClear(renderer); - - actorManager->draw(actorManager); - - SDL_RenderPresent(renderer); -} - -void update (Uint32 dt) { - actorManager->update(actorManager, dt); -} - -int main(int argc, const char * argv[]) -{ - - // SDL Initialization. TODO: Should have an initializer. - Uint32 startFrame = 0; - Uint32 endFrame = 0; - Uint32 lastTime = 0; - Uint32 dt; - Uint32 delay; - int done; - - init(); - loadAssets(); - - - done = 0; - focus = true; - - // Event Loop. - while (!done) { - startFrame = SDL_GetTicks(); - dt = startFrame - lastTime; - lastTime = startFrame; - - SDL_Event event; - while (SDL_PollEvent(&event)) { - if (event.type == SDL_QUIT) { - done = 1; - } - if (event.type == SDL_WINDOWEVENT) { - if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) { - focus = false; - } - if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { - focus = true; - } - } - } - - if (focus) { - update(dt); - draw(renderer); - } - - endFrame = SDL_GetTicks(); - - /* see if we have time to sleep */ - delay = 1000 / FPS - (endFrame - startFrame); - if (delay > 1000 / FPS) { - delay = 1000 / FPS; - } - SDL_Delay(delay); - } - - close(); - - return 0; -} - |