Skip to content

Commit

Permalink
Win32 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SeppoPakonen committed May 4, 2017
1 parent 86beaa2 commit 4ffb9e8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
44 changes: 33 additions & 11 deletions src/QuantumMinigolf/MinigolfDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ MinigolfDrawer::MinigolfDrawer() :
MemReadStream cmap_mono_mem(cmap_mono_brc, cmap_mono_brc_length);
cmap_mono = PNGRaster().LoadString(BZ2Decompress(cmap_mono_mem));

running = true;
stopped = false;
Thread::Start(THISBACK(Run));
Start();

PostCallback(THISBACK(Refresher));
}

MinigolfDrawer::~MinigolfDrawer() {
Stop();
}

void MinigolfDrawer::Start() {
running = true;
stopped = false;
Thread::Start(THISBACK(Run));
}

void MinigolfDrawer::Stop() {
running = false;
while (!stopped) Sleep(100);
}
Expand Down Expand Up @@ -142,6 +150,10 @@ void MinigolfDrawer::Run() {
}

void MinigolfDrawer::SetTrack(Track& track) {
Stop();

state = STATE_AIMING;

this->track = &track;

ballx = 550;
Expand All @@ -161,6 +173,7 @@ void MinigolfDrawer::SetTrack(Track& track) {
// for each new track, the position propagator must be rebuilt
simulator.BuildPositionPropagator(track.base);

Start();
}

void MinigolfDrawer::StopMoving() {
Expand All @@ -177,10 +190,11 @@ void MinigolfDrawer::StopMoving() {
}

void MinigolfDrawer::MouseMove(Point p, dword keyflags) {

if (state == STATE_AIMING) {
double dx = p.x - ballx;
double dy = p.y - bally;
int xoff = (GetSize().cx - WIDTH) / 2;
int yoff = (GetSize().cy - HEIGHT) / 2;
double dx = p.x - ballx - xoff;
double dy = p.y - bally - yoff;

racket_rphi = atan(dy / dx);
if (dx > 0)
Expand Down Expand Up @@ -222,9 +236,9 @@ void MinigolfDrawer::Paint(Draw& w) {
int width = track->base.GetWidth();
int height = track->base.GetHeight();

//ImageDraw id(sz);

ImageDraw id(width, height);
id.DrawRect(sz, White());
id.DrawRect(0,0,width,height, White());



Expand Down Expand Up @@ -314,7 +328,10 @@ void MinigolfDrawer::Paint(Draw& w) {
lock.Leave();


w.DrawImage(0, 0, wave);
ImageDraw bg(sz);
bg.DrawRect(sz, Black());
bg.DrawImage((sz.cx - width) / 2, (sz.cy - height) / 2, wave);
w.DrawImage(0,0,bg);
return;
}

Expand All @@ -334,8 +351,13 @@ void MinigolfDrawer::Paint(Draw& w) {
Font fnt = SansSerif(45);
Size txt_sz = GetTextSize(txt, fnt);

id.DrawText((sz.cx - txt_sz.cx) / 2, (sz.cy - txt_sz.cy) / 2, txt, fnt, clr);
id.DrawText((width - txt_sz.cx) / 2, (height - txt_sz.cy) / 2, txt, fnt, clr);
}

w.DrawImage(0,0,id);
ImageDraw bg(sz);
bg.DrawRect(sz, Black());
bg.DrawImage((sz.cx - width) / 2, (sz.cy - height) / 2,id);


w.DrawImage(0,0,bg);
}
2 changes: 2 additions & 0 deletions src/QuantumMinigolf/QuantumMinigolf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class MinigolfDrawer : public Ctrl {
MinigolfDrawer();
~MinigolfDrawer();

void Start();
void Stop();
void Run();
void Refresher();
void StopMoving();
Expand Down
8 changes: 5 additions & 3 deletions src/QuantumMinigolf/QuantumMinigolf.upp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ description "The game converted to U++ framework.\377";
uses
CtrlLib,
plugin/bz2,
plugin/png;
plugin/png,
plugin/z;

library
"fftw3 fftw3_threads fftw3f fftw3f_threads";
library(!WIN32) "fftw3 fftw3_threads fftw3f fftw3f_threads";

library(WIN32) "libfftw3-3 libfftw3f-3 libfftw3l-3";

file
Copying,
Expand Down

0 comments on commit 4ffb9e8

Please sign in to comment.