aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bounce.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/bounce.cpp b/bounce.cpp
index 6f5e66a..7c7e362 100644
--- a/bounce.cpp
+++ b/bounce.cpp
@@ -17,6 +17,7 @@
#include <proto/exec.h>
#include <proto/dos.h>
#include <intuition/intuition.h>
+#include <graphics/gels.h>
#include <stdint.h>
#include <stdlib.h>
@@ -70,6 +71,8 @@ __chip WORD ballSprite[] = { 0x0000, 0x0000,
WORD ballColors[] = { 0x0000, 0x00F0, 0x0F00 };
+// sprite struct
+
/**
* WindowPos
@@ -108,6 +111,8 @@ class AmigaWindow {
struct BallPos ballpos;
int bounceDirX;
int bounceDirY;
+ struct VSprite *vsprite;
+ struct GelsInfo *ginfo;
struct WindowPos winposition;
struct WindowSize winsize;
@@ -135,11 +140,36 @@ class AmigaWindow {
rp = window->RPort;
if(rp == nullptr) {
bad = true;
+ } else {
+ initSprite();
}
}
}
/**
+ * Sets up sprite
+ */
+ void initSprite() {
+ if(!bad) {
+ if(NULL == (vsprite = makeVSprite(&vsprite))) {
+ bad = true;
+ } else {
+ AddVSprite(vsprite, rp);
+ spriteDrawList();
+ }
+ }
+ }
+
+ /**
+ * Sprite redrawing routines
+ */
+ void spriteDrawList() {
+ SortGList(rp);
+ DrawGList(rp, ViewPortAddress(window));
+ RethinkDisplay();
+ }
+
+ /**
* Draws the bouncing ball on screen
*/
void drawBounce() {
@@ -195,6 +225,13 @@ class AmigaWindow {
* Cleans up window
*/
~AmigaWindow() {
+ if(vsprite != nullptr) {
+ RemVSprite(vsprite);
+ freeVSprite(vsprite);
+ vsprite = nullptr;
+ spriteDrawList();
+ cleanupGelSys(ginfo, rp);
+ }
if(window != nullptr) {
CloseWindow(window);
window = nullptr;