From ef14553ed723413a4a1beb38f2a87d32808b6345 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Apr 29 2021 12:49:40 +0000 Subject: update to latest functionality --- diff --git a/15.c b/15.c index e5ad9ea..6319b15 100644 --- a/15.c +++ b/15.c @@ -83,8 +83,8 @@ void draw() { translate(1, 1); if (mouseDown("left")) { - double mx = transformedMouseX(); - double my = transformedMouseY(); + double mx = mouseTransformedX(); + double my = mouseTransformedY(); if (!selected) { selected = groupSpriteByPoint(group, mx, my, TRUE); if (selected) { @@ -121,11 +121,11 @@ void draw() { int main() { - worldSetTitle("15"); - worldSetInit(&init); - worldSetDraw(&draw); - worldSetSize(6*CELLSIZE, 6*CELLSIZE); - worldSetVariableFrameRate(); - worldRun(); + windowSetTitle("15"); + windowSetInit(&init); + windowSetDraw(&draw); + windowSetSize(6*CELLSIZE, 6*CELLSIZE); + windowSetVariableFrameRate(); + windowRun(); return 0; } diff --git a/2048.c b/2048.c index 52e4ab8..1211e47 100644 --- a/2048.c +++ b/2048.c @@ -159,7 +159,7 @@ void draw() { if (keyWentDown("up")) fall(-1, 0); if (keyWentDown("down")) fall( 1, 0); - double dp = speed * worldGetFrameTime(); + double dp = speed * windowGetFrameTime(); int score = 0; for(int r = 0; r < MAPSIZE; ++r) { for(int c = 0; c < MAPSIZE; ++c) { @@ -194,7 +194,7 @@ void draw() { char buf[20]; sprintf(buf, "%d", score); - worldSetTitle(buf); + windowSetTitle(buf); drawSprites(); restoreState(); @@ -202,11 +202,11 @@ void draw() { int main() { - worldSetInit(&init); - worldSetDraw(&draw); - worldSetSize(MAPSIZE*CELLSIZE, MAPSIZE*CELLSIZE); - worldSetVariableFrameRate(); - worldRun(); + windowSetInit(&init); + windowSetDraw(&draw); + windowSetSize(MAPSIZE*CELLSIZE, MAPSIZE*CELLSIZE); + windowSetVariableFrameRate(); + windowRun(); return 0; } diff --git a/fractal.c b/fractal.c index c06788c..e7b4266 100644 --- a/fractal.c +++ b/fractal.c @@ -52,7 +52,7 @@ void init() { void draw() { - double dt = worldGetFrameTime(); + double dt = windowGetFrameTime(); int changed = 0; if (mouseDown("middle")) { @@ -80,10 +80,10 @@ void draw() { int main() { - worldSetTitle("Fractal"); - worldSetInit(&init); - worldSetDraw(&draw); - worldSetFrameRateEx(1, 100); - worldRun(); + windowSetTitle("Fractal"); + windowSetInit(&init); + windowSetDraw(&draw); + windowSetFrameRateEx(1, 100); + windowRun(); return 0; } diff --git a/lamps.c b/lamps.c index 350cdeb..4f7f1f1 100644 --- a/lamps.c +++ b/lamps.c @@ -44,7 +44,7 @@ void draw() { } if (mouseWentDown("left")) - toggle((int)transformedMouseY(), (int)transformedMouseX()); + toggle((int)mouseTransformedY(), (int)mouseTransformedX()); if (keyWentDown("space")) toggleRandom(); @@ -53,12 +53,12 @@ void draw() { int main() { - worldSetTitle("Lamps"); - worldSetSize(SIZE*LAMPSIZE, SIZE*LAMPSIZE); - worldSetVariableFrameRate(); - worldSetInit(&init); - worldSetDraw(&draw); - worldRun(); + windowSetTitle("Lamps"); + windowSetSize(SIZE*LAMPSIZE, SIZE*LAMPSIZE); + windowSetVariableFrameRate(); + windowSetInit(&init); + windowSetDraw(&draw); + windowRun(); return 0; } diff --git a/snake.c b/snake.c index 86995f3..b1d48f0 100644 --- a/snake.c +++ b/snake.c @@ -296,8 +296,8 @@ void init() { void draw() { - double cx = worldGetWidth()/2.0; - double cy = worldGetHeight()/2.0; + double cx = windowGetWidth()/2.0; + double cy = windowGetHeight()/2.0; if (mode == PLAY) { int prevdx = snake[0][0] - snake[1][0]; @@ -318,14 +318,14 @@ void draw() { drawSprites(); fill(colorByRGBA(1, 1, 1, 0.25)); - rect(0, 0, worldGetWidth(), worldGetHeight()); + rect(0, 0, windowGetWidth(), windowGetHeight()); noFill(); textAlign(HALIGN_CENTER, HALIGN_CENTER); textSize(24); - text("Game Over", cx, cy); + text(cx, cy, "Game Over"); textSize(12); - text("press enter", cx, cy + 24); + text(cx, cy + 24, "Game Over"); if (keyWentDown("return")) mode = MENU; if (keyWentDown("escape")) mode = MENU; } else @@ -333,12 +333,12 @@ void draw() { drawSprites(); fill(colorByRGBA(1, 1, 1, 0.25)); - rect(0, 0, worldGetWidth(), worldGetHeight()); + rect(0, 0, windowGetWidth(), windowGetHeight()); noFill(); textAlign(HALIGN_CENTER, VALIGN_CENTER); textSize(24); - text("Press enter to start", cx, cy); + text(cx, cy, "Press enter to start"); if (keyWentDown("return")) mode = PLAY; if (keyWentDown("escape")) mode = MENU; } else @@ -348,12 +348,12 @@ void draw() { textSize(24); int x = cx - 100; int y = cy - 24*3; - text("Select difficulty level:", x, y); y += 24; - text("1 - very easy", x, y); y += 24; - text("2 - easy", x, y); y += 24; - text("3 - medium", x, y); y += 24; - text("4 - hard", x, y); y += 24; - text("5 - very hard", x, y); y += 24; + text(x, y, "Select difficulty level:"); y += 24; + text(x, y, "1 - very easy" ); y += 24; + text(x, y, "2 - easy" ); y += 24; + text(x, y, "3 - medium" ); y += 24; + text(x, y, "4 - hard" ); y += 24; + text(x, y, "5 - very hard" ); y += 24; difficulty = 0; if (keyWentDown("any 1")) difficulty = 1; if (keyWentDown("any 2")) difficulty = 2; @@ -361,17 +361,17 @@ void draw() { if (keyWentDown("any 4")) difficulty = 4; if (keyWentDown("any 5")) difficulty = 5; if (difficulty) restart(); - if (keyWentDown("escape")) worldStop(); + if (keyWentDown("escape")) windowStop(); } } int main() { - worldSetTitle("Snake"); - worldSetWidth(SIZE * WIDTH); - worldSetHeight(SIZE * HEIGHT); - worldSetFrameRate(FRAMERATE); - worldSetInit(&init); - worldSetDraw(&draw); - worldRun(); + windowSetTitle("Snake"); + windowSetWidth(SIZE * WIDTH); + windowSetHeight(SIZE * HEIGHT); + windowSetFrameRate(FRAMERATE); + windowSetInit(&init); + windowSetDraw(&draw); + windowRun(); return 0; } diff --git a/sokoban.c b/sokoban.c index 3855f1a..718c6a1 100644 --- a/sokoban.c +++ b/sokoban.c @@ -79,8 +79,8 @@ void loadLevel() { } while (c != EOF); fclose(f); - worldSetWidth(maxX + 32); - worldSetHeight(maxY + 32); + windowSetWidth(maxX + 32); + windowSetHeight(maxY + 32); } @@ -123,7 +123,7 @@ void init() { void draw() { - double dt = worldGetFrameTime(); + double dt = windowGetFrameTime(); double x = spriteGetX(player); double y = spriteGetY(player); @@ -165,15 +165,15 @@ void draw() { noFill(); stroke(colorByName("white")); textAlign(HALIGN_CENTER, VALIGN_BOTTOM); - text("R - restart level, PgUp - previous level, PgDown - next level", worldGetWidth()/2, worldGetHeight() - 10); + text(windowGetWidth()/2, windowGetHeight() - 10, "R - restart level, PgUp - previous level, PgDown - next level"); } int main() { - worldSetTitle("Sokoban"); - worldSetInit(&init); - worldSetDraw(&draw); - worldSetFrameRateEx(10, 100); - worldRun(); + windowSetTitle("Sokoban"); + windowSetInit(&init); + windowSetDraw(&draw); + windowSetFrameRateEx(10, 100); + windowRun(); return 0; } diff --git a/timer.c b/timer.c index 305bf58..7c031a6 100644 --- a/timer.c +++ b/timer.c @@ -21,10 +21,10 @@ void init() { void draw() { if (started) { if (alarm) { - subSeconds += worldGetFrameTime(); + subSeconds += windowGetFrameTime(); while(subSeconds >= 1) subSeconds -= 1; } else { - subSeconds += worldGetFrameTime(); + subSeconds += windowGetFrameTime(); while(subSeconds >= 1) { subSeconds -= 1; --seconds; } while(seconds < 0) { --minutes; seconds += 60; } while(minutes < 0) { --hours; minutes += 60; } @@ -39,7 +39,7 @@ void draw() { } saveState(); - translate( worldGetWidth()/2.0, worldGetHeight()/2.0 ); + translate( windowGetWidth()/2.0, windowGetHeight()/2.0 ); textAlign(HALIGN_CENTER, VALIGN_CENTER); @@ -53,8 +53,8 @@ void draw() { textSize(64); if (alarm) stroke(colorByRGBA(0, 0, 0, subSeconds)); - double mx = transformedMouseX(); - double my = transformedMouseY(); + double mx = mouseTransformedX(); + double my = mouseTransformedY(); if (fabs(mx) <= 0.45*size && fabs(my) <= 0.45*size) { *value += mouseScrolledY(); while(*value < 0) *value += 60; @@ -63,15 +63,12 @@ void draw() { if (mouseWentDown("right")) *value = 30; } - char buf[32] = {}; - sprintf(buf, "%d", *value / 10); - text(buf, -0.2*size, 0); - sprintf(buf, "%d", *value % 10); - text(buf, 0.2*size, 0); + textf(-0.2*size, 0, "%d", *value / 10); + textf( 0.2*size, 0, "%d", *value % 10); if (i > 0) { translate( -size/2, 0 ); - text(":", 0, 0); + text(0, 0, ":"); } restoreState(); @@ -96,18 +93,18 @@ void draw() { double buttonHeight = size*0.5; translate(-0.5*buttonWidth, 0.75*size); - double mx = transformedMouseX(); - double my = transformedMouseY(); + double mx = mouseTransformedX(); + double my = mouseTransformedY(); int click = mouseWentDown("left") && fabs(mx) <= 0.4*buttonWidth && fabs(my) <= 0.4*buttonHeight; rect(-0.4*buttonWidth, -0.4*buttonHeight, 0.8*buttonWidth, 0.8*buttonHeight); if (started) { - text("pause", 0, 0); + text(0, 0, "pause"); if (click) { soundStop(alarmSound); started = alarm = FALSE; } } else { - text("start", 0, 0); + text(0, 0, "start"); if (click) { subSeconds = 0; started = TRUE; } } @@ -115,7 +112,7 @@ void draw() { mx -= buttonWidth; click = mouseWentDown("left") && fabs(mx) <= 0.4*buttonWidth && fabs(my) <= 0.4*buttonHeight; rect(-0.4*buttonWidth, -0.4*buttonHeight, 0.8*buttonWidth, 0.8*buttonHeight); - text("reset", 0, 0); + text(0, 0, "reset"); if (click) { soundStop(alarmSound); started = alarm = FALSE; @@ -129,9 +126,9 @@ void draw() { int main() { - worldSetVariableFrameRate(); - worldSetInit(&init); - worldSetDraw(&draw); - worldRun(); + windowSetVariableFrameRate(); + windowSetInit(&init); + windowSetDraw(&draw); + windowRun(); return 0; } diff --git a/tree.c b/tree.c index 053356d..d4c92f6 100644 --- a/tree.c +++ b/tree.c @@ -112,9 +112,9 @@ void init() { void draw() { - double w = worldGetWidth(); - double h = worldGetHeight(); - t += worldGetFrameTime(); + double w = windowGetWidth(); + double h = windowGetHeight(); + t += windowGetFrameTime(); if (keyWentDown("space")) seed = randomNumber(0, 1000000); @@ -131,9 +131,9 @@ void draw() { int main() { - worldSetVariableFrameRate(); - worldSetResizable(TRUE); - worldSetInit(&init); - worldSetDraw(&draw); - worldRun(); + windowSetVariableFrameRate(); + windowSetResizable(TRUE); + windowSetInit(&init); + windowSetDraw(&draw); + windowRun(); }