Hi,
I've been a reader of this forum for a long time but never bothered to create a forum profile, I was happy stalking you guys.
Until now, when I have a problem I need help with.
The thing is, a year ago or so I started coding a "chipdisk". It's a remnant from the old demoscene in 80's/90's. It's a basically a music player that is supposed to play some .mod files from my old "group" and look ok while it plays, maybe with some info and so on.
I'm using VS Express 2008 with Dark GDK.
Enough background, the problem is it's stopped working from where I left it a year ago. At first it wouldn't compile at all but I sorted that out, it was the old atls.lib stuff messing about an' that.
It compiled and looked like it should, but! I can't click any of the buttons in the player, it's like the dbSpriteHit just doesn't register, or my variables are being reset immediately. I just can't see any problems in the code.
It's in beginner stages so it's not very long yet, I'll just post the entire code here shall I?
If you need the whole project (just a few pics for now) I'll put code and pics in a rar and attach it.
Thanks for any comments and/or help!
#include "DarkGDK.h"
// declaring global variables and functions
void setupGraphics(void);
void mouse(void); // Checks mouse - no interaction
void mouseAction(void); // Mouse interaction
void debug(void);
void cleanUp(void);
// which sprite is clicked
int spriteClicked = 0;
// which sprite is hovered over
int spriteHovered = 0;
// which sprite was last clicked (stays checked after spriteClicked turns to nil
int lastClicked = 0;
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn();
dbSyncRate(60);
// disabling escapekey as standard termination
dbDisableEscapeKey();
// hides windows mousepointer
dbHideMouse();
// remove titlebar from window
dbSetWindowLayout(0, 0, 0);
// call function to load images and making sprites
setupGraphics();
// our main loop - program cycle
while ( LoopGDK() )
{
// pasting backdrop
dbPasteImage(1, 0, 0);
// pasting mouse and checking mouseclicks
mouse();
// mouse action and animation of sprites while clicked
mouseAction();
// use this for debugging while running app
debug();
// minimize window
if (spriteClicked == 11)
dbMinimizeWindow();
// termination of application below - escapekey or click the 'x'
if ( dbEscapeKey ( ) )
break;
if (spriteClicked == 10)
break;
// update the screen
dbSync ( );
}
// when the user presses escape the code will break out to this location
cleanUp();
// return back to windows
return;
}
void setupGraphics() // Sets up all sprites and backdrops
{
dbSetImageColorKey (0, 0, 0);
dbCD("media");
// backdrop
dbLoadImage("mdisk_background.bmp", 1);
// mouse cursor
dbLoadImage("mdisk_cursor.bmp", 100);
dbSprite(100, dbMouseX(), dbMouseY(), 100);
dbOffsetSprite(100, 0, 23);
dbSetSpritePriority(100, 1);
dbLoadImage("mdisk_cursorpoint.bmp", 101);
dbSprite(101, dbMouseX(), dbMouseY(), 101);
// termination button
dbLoadImage("mdisk_close.bmp", 10);
dbSprite(10, 600, 10, 10);
dbSetSpriteAlpha(10, 100);
// minimize button
dbLoadImage("mdisk_minimize.bmp", 11);
dbSprite(11, 560, 28, 11);
dbSetSpriteAlpha(11, 100);
// play button ** Frame 1 = Play - Frame 2 = Pause **
dbCreateAnimatedSprite(12, "mdisk_playpause.bmp", 2, 1, 12);
dbSprite(12, 52, 216, 12);
dbSetSpriteFrame(12, 2);
// nfo button
dbLoadImage("mdisk_nfonew.bmp",13);
dbSprite(13, 41, 308, 13);
dbRotateSprite(13, 30);
// back button
dbLoadImage("mdisk_back.bmp", 14);
dbSprite(14, 50, 272, 14);
// forward button
dbLoadImage("mdisk_forw.bmp", 15);
dbSprite(15, 80, 267, 15);
// Treelights test
//dbCreateAnimatedSprite(21, "mdisk_treelight.bmp", 4, 2, 21);
//dbSprite(21, 320, 170, 21);
}
void mouse()
{
// is mouse clicked? then check what it's pointing at
if (dbMouseClick() == 1)
{
lastClicked = dbSpriteHit(101, 0);
spriteClicked = dbSpriteHit(101, 0);
}else spriteClicked = 0;
spriteHovered = dbSpriteHit(101, 0);
// Draws the mouse and the pointersprite at mouseXY
dbSprite(100, dbMouseX() + 1, dbMouseY() - 1, 100);
dbSprite(101, dbMouseX(), dbMouseY(), 101);
}
void mouseAction()
{
// COLOURING SPRITE RED WHEN HOVERED BY MOUSE
if (dbSpriteHit(101, spriteHovered) == 1)
dbSetSpriteDiffuse(spriteHovered, 255, 200, 200);
else dbSetSpriteDiffuse(spriteHovered, 255, 255 , 255);
// lowers sprite when clicked
if (spriteClicked > 0)
dbOffsetSprite(spriteClicked, 0, -2);
// puts sprites back after offsetting, checks all
if (spriteClicked == 0)
for (int i = 1; i < 50; i++)
dbOffsetSprite(i, 0, 0);
// this is for changing from play to pause and vice versa
if (spriteClicked == 0)
if (lastClicked == 12)
{
if (dbSpriteFrame(12) == 1)
{
dbSetSpriteFrame(12, 2);
lastClicked = 0;
}
if (dbSpriteFrame(12) == 2)
dbSetSpriteFrame(12, 1);
}
}
void debug()
{
double mousex = dbSpriteX(101);
double mousey = dbSpriteY(101);
double mouseclick = dbMouseClick();
double mouseover = dbSpriteHit(101, 0);
double debugSpriteClicked = spriteClicked;
double debugLastClicked = lastClicked;
dbText(180, 0, "MouseX:");
dbText(180, 15, "MouseY:");
dbText(148, 30, "Mouseclick:");
dbText(100, 45, "Points at sprite:");
dbText(116, 60, "Sprite clicked:");
dbText(132, 75, "Last clicked:");
dbSetCursor(240, 0);
dbPrint(mousex);
dbSetCursor(240, 15);
dbPrint(mousey);
dbSetCursor(240, 30);
dbPrint(mouseclick);
dbSetCursor(240, 45);
dbPrint(mouseover);
dbSetCursor(240, 60);
dbPrint(debugSpriteClicked);
dbSetCursor(240, 75);
dbPrint(debugLastClicked);
}
void cleanUp()
{
for ( int i = 1; i < 1000; i++ )
{
if (dbSpriteExist(i))
dbDeleteSprite(i);
if (dbImageExist(i))
dbDeleteImage(i);
}
}
My hovercraft is full of eels