Skip to content

Commit

Permalink
add multiscene demo
Browse files Browse the repository at this point in the history
  • Loading branch information
redthing1 committed Jul 16, 2024
1 parent b43999c commit 55f06d8
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
15 changes: 15 additions & 0 deletions demo/multiscene/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.dub
docs.json
__dummy.html
docs/
/multiscene
multiscene.so
multiscene.dylib
multiscene.dll
multiscene.a
multiscene.lib
multiscene-test-*
*.exe
*.o
*.obj
*.lst
8 changes: 8 additions & 0 deletions demo/multiscene/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name "multiscene"
description "multiple scenes"
authors "redthing1"
copyright "Copyright © 2020, redthing1"
license "proprietary"
dependency "reng" path="../.."

subConfiguration "reng" "lib-minimal"
28 changes: 28 additions & 0 deletions demo/multiscene/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import std.stdio;

import re;
import re.math;
import std.stdio;
import play;

class Game : Core {
enum WIDTH = 800;
enum HEIGHT = 400;

this() {
super(WIDTH, HEIGHT, "multiscene");
}

override void initialize() {
default_resolution = Vector2(WIDTH / 4, HEIGHT / 4);
content.paths ~= "../content/";

load_scenes([new PlayScene()]);
}
}

void main() {
auto game = new Game(); // init game
game.run();
game.destroy(); // clean up
}
38 changes: 38 additions & 0 deletions demo/multiscene/source/play.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module play;

import re;
import re.gfx;
import re.gfx.shapes.rect;
import re.ng.camera;
import re.math;
import re.phys.kin2d;

static import raylib;

class PlayScene : Scene2D {
override void on_start() {
resolution = Vector2(100, 100);
output_rect = Rectangle(
0, 0,
Core.window.screen_width / 2,
Core.window.screen_height
);

auto bg_tween = Tweener.tween(clear_color, Colors.DARKGRAY,
Colors.LIGHTGRAY, 2, &Ease.QuadIn);
bg_tween.start();

auto box1 = create_entity("box1", Vector2(20, 20));
box1.add_component(new ColorRect(Vector2(8, 8), Colors.BLUE));
auto box1_body = box1.add_component!KinBody2D();
box1_body.angular_accel = 0.1;

auto box2 = create_entity("box2", Vector2(40, 20));
box2.add_component(new ColorRect(Vector2(8, 8), Colors.RED));
auto box2_body = box2.add_component!KinBody2D();
box2_body.angular_accel = -0.07;

// follow the first box
cam.entity.add_component(new CameraFollow2D(box1, 0.05));
}
}

0 comments on commit 55f06d8

Please sign in to comment.