-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af19f87
commit 69de96f
Showing
4 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "ship_sprite.hh" | ||
|
||
ship_sprite_t::ship_sprite_t() : | ||
sprite_t(), | ||
frames_in_anim(0) | ||
{ | ||
} | ||
|
||
void ship_sprite_t::draw_onto(Screen *screen) { | ||
if (frame_ == 0) { | ||
frames_in_anim++; | ||
if (frames_in_anim > 3) { | ||
frames_in_anim = 0; | ||
frame_ = 1; | ||
} | ||
} else if (frame_ == 1) { | ||
frames_in_anim++; | ||
if (frames_in_anim > 3) { | ||
frames_in_anim = 0; | ||
frame_ = 0; | ||
} | ||
} else if (frame_ == 2) { | ||
frames_in_anim++; | ||
if (frames_in_anim > 3) { | ||
frames_in_anim = 0; | ||
frame_ = 3; | ||
} | ||
} else if (frame_ == 3) { | ||
frames_in_anim++; | ||
if (frames_in_anim > 3) { | ||
frames_in_anim = 0; | ||
explode_anims++; | ||
if (explode_anims > 10) { | ||
set_active(false); | ||
frame_ = 0; | ||
} else { | ||
frame_ = 2; | ||
} | ||
} | ||
} | ||
sprite_t::draw_onto(screen); | ||
} | ||
|
||
void ship_sprite_t::destroy_sprite(void) { | ||
frame_ = 2; | ||
frames_in_anim = 0; | ||
explode_anims = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
#include <cstdint> | ||
|
||
#include "sprite.hh" | ||
|
||
class ship_sprite_t : public sprite_t { | ||
public: | ||
ship_sprite_t(); | ||
|
||
virtual void draw_onto(Screen *screen) override; | ||
virtual void destroy_sprite(void); | ||
|
||
private: | ||
uint32_t frames_in_anim; | ||
uint32_t explode_anims; | ||
}; |