]>
git.r.bdr.sh - rbdr/super-polarity/blob - src/actor.c
32028a1ea2c5378249fdff09b2aa72a773ec83ef
5 // Created by Ruben Beltran del Rio on 8/14/13.
6 // Copyright (c) 2013 Abuguet. All rights reserved.
12 SDL_Renderer
*renderer
;
14 void actorUpdate(Actor
*this, Uint32 dt
) {
15 this->textureBox
.x
= this->pos
.x
;
16 this->textureBox
.y
= this->pos
.y
;
17 this->angle
= (Uint32
)(this->angle
+ dt
/ 5) % 360;
20 void actorDraw(Actor
*this) {
21 SDL_RenderCopyEx(renderer
, this->texture
, NULL
, &this->textureBox
, this->angle
, NULL
, SDL_FLIP_NONE
);
24 // This constructor is pretty much dumb. So, don't take it as anything final.
25 Actor
* createActor () {
26 Actor
*actor
= malloc(sizeof(Actor
*));
29 actor
->update
= actorUpdate
;
30 actor
->draw
= actorDraw
;
34 SDL_Surface
*benSurface
;
35 benSurface
= IMG_Load("data/img/static/ben.png");
36 actor
->texture
= SDL_CreateTextureFromSurface(renderer
, benSurface
);
37 actor
->textureBox
.x
= 230;
38 actor
->textureBox
.y
= 150;
39 actor
->textureBox
.w
= 180;
40 actor
->textureBox
.h
= 180;
41 SDL_FreeSurface(benSurface
);