summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sprite.cpp11
-rw-r--r--sprite.h8
-rw-r--r--src/objects/obj_control.cpp5
3 files changed, 16 insertions, 8 deletions
diff --git a/sprite.cpp b/sprite.cpp
index 260c54f..493864e 100644
--- a/sprite.cpp
+++ b/sprite.cpp
@@ -1,8 +1,15 @@
#include "sprite.h"
-Sprite::Sprite(const unsigned char *image,unsigned int image_len)
- :image(image),image_len(image_len){
+Sprite::Sprite(const unsigned char *image,unsigned int image_len){
sf_texture.loadFromMemory(image,image_len);
sf_sprite.setTexture(sf_texture);
}
+
+int Sprite::width() const {
+ return sf_texture.getSize().x;
+}
+
+int Sprite::height() const {
+ return sf_texture.getSize().y;
+}
diff --git a/sprite.h b/sprite.h
index b5d9e7d..a40b641 100644
--- a/sprite.h
+++ b/sprite.h
@@ -4,11 +4,13 @@
class Sprite{
-public:
- const unsigned char *image;
- unsigned int image_len;
sf::Texture sf_texture;
+
+public:
sf::Sprite sf_sprite;
Sprite(const unsigned char *image,unsigned int image_len);
+
+ int width() const;
+ int height() const;
};
diff --git a/src/objects/obj_control.cpp b/src/objects/obj_control.cpp
index 5f8778c..66b481c 100644
--- a/src/objects/obj_control.cpp
+++ b/src/objects/obj_control.cpp
@@ -1,13 +1,11 @@
-OUT #include <cstdio>
OUT #include <cstdlib>
-double yd=0;
+static double yd=0;
EVENT(create){
draw_set_font(fnt_liber);
x=10;
y=240;
- log("Control object wow!");
instance_create<obj_hoi>(20,20);
}
@@ -15,6 +13,7 @@ EVENT(step){
x++;
y+=yd;
yd+=(double)rand()/RAND_MAX*2-y/240;
+ yd*=0.99;
}
EVENT(draw){