diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2019-03-11 19:27:13 -0400 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2019-03-11 19:27:13 -0400 |
commit | 422f720e65e7505dac76d1b20e1497a8943cf46d (patch) | |
tree | 926e769f480bebe37b7f5058ed27167c27e3ffe4 /bounce.cpp | |
parent | 549bc32d822958a635c32f2fdd34f0395c34e50c (diff) | |
download | bounce-422f720e65e7505dac76d1b20e1497a8943cf46d.tar.gz bounce-422f720e65e7505dac76d1b20e1497a8943cf46d.tar.bz2 bounce-422f720e65e7505dac76d1b20e1497a8943cf46d.zip |
Diffstat (limited to 'bounce.cpp')
-rw-r--r-- | bounce.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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; |