summaryrefslogtreecommitdiff
path: root/object_base.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-30 09:38:02 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-30 09:38:02 +0100
commitf62f270de05ebe5a71ef2e66a1a0f54b4ed9dc61 (patch)
tree19957fe8bc0e0bccbce6c73fef6b6092ed705807 /object_base.cpp
parentc8a110cdeca8c23b88d6908f0b06231847c9e722 (diff)
Working sprites and instance_create
Diffstat (limited to 'object_base.cpp')
-rw-r--r--object_base.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/object_base.cpp b/object_base.cpp
index b16acc1..18d7e3a 100644
--- a/object_base.cpp
+++ b/object_base.cpp
@@ -1,4 +1,5 @@
#include <iostream>
+#include <cassert>
#include "object_base.h"
#include "library.h"
@@ -8,7 +9,7 @@ using namespace std;
Object::Object(void){
log("Object constructed");
}
-Object::Object(double _x,double _y):x(_x),y(_y){
+Object::Object(double x,double y):x(x),y(y){
log("Object constructed at position");
}
Object::~Object(void){
@@ -18,4 +19,14 @@ Object::~Object(void){
void Object::create(void){}
void Object::destroy(void){}
void Object::step(void){}
-void Object::draw(void){}
+
+void Object::draw(void){
+ if(!sprite_index){
+ return;
+ }
+ if(!sprite_index->fl_image){
+ sprite_index->fl_image=new Fl_PNG_Image(nullptr,sprite_index->image,sprite_index->image_len);
+ assert(!sprite_index->fl_image->fail());
+ }
+ sprite_index->fl_image->draw((int)x,(int)y);
+}