Okay, let's try these parts.
Initializing the screen
DarkCap()
{
dbSetDisplayMode (bgWidth, bgHeight, pixelDepth);
dbSetWindowOff();
dbSyncOn ( );
dbSyncRate ( 0 );
dbDisableEscapeKey ( );
dbRandomize ( dbTimer ( ) );
currentStage = design;
}
And the loop I'm running
void DarkCap::Design()
{
dbDrawSpritesFirst();
dbRect tempRect (0, 0, 0, 0);
Mouse &mouse = *Mouse::Instance();
mouse.Sync();
// load the capsule info
Image imgCapsule("media\\myship.png",1);
Capsule sprCapsule (LEFTSPACE + 26, TOPSPACE + 12, imgCapsule);
Capsule sprCapsule2 (LEFTSPACE + 78, TOPSPACE + 12, imgCapsule);
sprCapsule.Wake();
sprCapsule2.Wake();
sprCapsule.SetPriority(5);
sprCapsule2.SetPriority(5);
CapLayout Layout (600, 600);
// here's the panel for the right side
Panel imgPanel(200, 600);
imgPanel.Clr(Beige);
Sprite sprPanel (600, 0, imgPanel);
// let's practice some paddle action
Image imgPaddle ("media\\paddle.png");
Paddle sprPaddle (imgPaddle);
sprPaddle.SetOffset(sprPaddle.Width()/2, 0);
sprPaddle.SetPriority(10);
// lets set up the ball
Image imgCapBall ("media\\CapBall.png", 1);
CapBall sprBall (imgCapBall);
sprBall.MoveTo(400, 300);
sprBall.SetPriority(10);
Layout.Update();
Sprite sprLayout(0, 0, Layout);
Layout.CopyFromImage(imgCapsule, tempRect, 119, 120);
dbInk (dbRGB(0, 0, 0), dbRGB(0,0,0));
mouse.Visible(false);
while (!dbEscapeKey()) {
if (mouse.ClickStat(2)) {
sprCapsule.Kill();
sprCapsule2.Kill();
}
if (mouse.ClickStat(3)){
sprCapsule.Wake();
sprCapsule2.Wake();
}
sprCapsule.Update();
sprCapsule2.Update();
sprBall.Update();
sprPaddle.Update();
mouse.DisplayStat(605, 100);
dbSync();
if (sprBall.CollideWith(sprPaddle)) ;
dbSetCursor(500, 300);
dbPrint((LONGLONG)dbScreenFPS());
mouse.Sync();
}
currentStage = end;
}
I'm sizing at 800 x 600. The left (Layout) 600 x 600 is a sprite place holding an image on which I've drawn a grid (for design purposes right now.) The right-most (sprPanel) 200 x 600 is another sprite/image to color the remaining background. However, at the moment it also has 78 sprites above it from which I'll click and drag to the layout in the design phase.
sprCapsule and sprCapsule2 are a couple of sprites I put in place to test the change phase of the capsules which I test with clicks on buttons 2 & 3. If they're in shrink mode, which they're generally not, they update each cycle. Otherwise they just return from the call to Update().
All that's left is the sprPaddle, which is based on a class derived from my Sprite class. Once set up it updates each cycle by tracking the X position of the mouse. sprBall is the ball, which also updates its position using floats.
And finally, though I don't know why I put this after the dbSync(), I check for collision. The actual workings take place in the CollideWith() function but the condition is left there for when I have to add sound to the process.
Lilith, Night Butterfly
I'm not a programmer but I play one in the office