updated to latest version of blah

This commit is contained in:
Noel Berry 2022-02-12 13:03:02 -08:00
parent 37a5afc52c
commit 6405f5c897
18 changed files with 113 additions and 151 deletions

View File

@ -11,37 +11,20 @@ add_subdirectory(libs/blah)
# add our source
add_executable(game
src/main.cpp
src/world.h
src/world.cpp
src/game.h
src/game.cpp
src/content.h
src/content.cpp
src/masks.h
src/factory.h
src/factory.cpp
src/assets/sprite.h
src/assets/sprite.cpp
src/assets/tileset.h
src/assets/tileset.cpp
src/components/animator.h
src/components/animator.cpp
src/components/collider.h
src/components/collider.cpp
src/components/player.h
src/components/player.cpp
src/components/mover.h
src/components/mover.cpp
src/components/tilemap.h
src/components/tilemap.cpp
src/components/hurtable.h
src/components/hurtable.cpp
src/components/timer.h
src/components/timer.cpp
src/components/enemy.h
src/components/ghost_frog.h
src/components/ghost_frog.cpp
src/components/orb.h
src/components/orb.cpp
)
@ -52,13 +35,3 @@ if( ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set_target_properties(game PROPERTIES LINK_FLAGS "-s USE_SDL=2 -s USE_WEBGL2=1 --preload-file ${CMAKE_SOURCE_DIR}/content@/content")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif()
# copy SDL2 to the build directory
set(SDL2_DLL "" CACHE FILEPATH "SDL2 DLL Path")
if (SDL2_ENABLED)
if (EXISTS ${SDL2_DLL})
add_custom_command(
TARGET game POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${SDL2_DLL} $<TARGET_FILE_DIR:game>)
endif()
endif()

@ -1 +1 @@
Subproject commit 78b8140f539b0d0911b4426826201fcf95e568bf
Subproject commit 9beb7eff58ae78810fa7f4d9830f8c46c0c0531a

View File

@ -28,7 +28,7 @@ namespace TL
};
String name;
Vec2 origin;
Vec2f origin;
Vector<Animation> animations;
const Animation* get_animation(const String& name) const;

View File

@ -1,9 +1,10 @@
#include "tileset.h"
#include "../game.h"
using namespace TL;
const Subtexture& Tileset::random_tile() const
{
int i = Calc::rand_int(columns * rows);
int i = Game::rand_int(0, columns * rows);
return tiles[i];
}

View File

@ -72,11 +72,11 @@ void Animator::render(Batch& batch)
if (in_valid_state())
{
batch.push_matrix(
Mat3x2::create_transform(entity()->position + offset, m_sprite->origin, scale, 0));
Mat3x2f::create_transform(entity()->position + offset, m_sprite->origin, scale, 0));
auto& anim = m_sprite->animations[m_animation_index];
auto& frame = anim.frames[m_frame_index];
batch.tex(frame.image, Vec2::zero, Color::white);
batch.tex(frame.image, Vec2f::zero, Color::white);
batch.pop_matrix();
}

View File

@ -16,7 +16,7 @@ namespace TL
float m_frame_counter = 0;
public:
Vec2 scale = Vec2::one;
Vec2f scale = Vec2f::one;
Point offset = Point::zero;
Animator() = default;

View File

@ -8,7 +8,7 @@ Collider::Collider()
active = false;
}
Collider Collider::make_rect(const RectI& rect)
Collider Collider::make_rect(const Recti& rect)
{
Collider collider;
collider.m_shape = Shape::Rect;
@ -32,13 +32,13 @@ Collider::Shape Collider::shape() const
return m_shape;
}
RectI Collider::get_rect() const
Recti Collider::get_rect() const
{
BLAH_ASSERT(m_shape == Shape::Rect, "Collider is not a Rectangle");
return m_rect;
}
void Collider::set_rect(const RectI& value)
void Collider::set_rect(const Recti& value)
{
BLAH_ASSERT(m_shape == Shape::Rect, "Collider is not a Rectangle");
m_rect = value;
@ -142,7 +142,7 @@ void Collider::render(Batch& batch)
{
static const Color color = Color::red;
batch.push_matrix(Mat3x2::create_translation(entity()->position));
batch.push_matrix(Mat3x2f::create_translation(entity()->position));
if (m_shape == Shape::Rect)
{
@ -169,8 +169,8 @@ void Collider::render(Batch& batch)
bool TL::Collider::rect_to_rect(const Collider* a, const Collider* b, Point offset)
{
RectI ar = a->m_rect + a->entity()->position + offset;
RectI br = b->m_rect + b->entity()->position;
Recti ar = a->m_rect + a->entity()->position + offset;
Recti br = b->m_rect + b->entity()->position;
return ar.overlaps(br);
}
@ -178,7 +178,7 @@ bool TL::Collider::rect_to_rect(const Collider* a, const Collider* b, Point offs
bool TL::Collider::rect_to_grid(const Collider* a, const Collider* b, Point offset)
{
// get a relative rectangle to the grid
RectI rect = a->m_rect + a->entity()->position + offset - b->entity()->position;
Recti rect = a->m_rect + a->entity()->position + offset - b->entity()->position;
// get the cells the rectangle overlaps
int left = Calc::clamp((int)Calc::floor(rect.x / (float)b->m_grid.tile_size), 0, b->m_grid.columns);

View File

@ -20,12 +20,12 @@ namespace TL
Collider();
static Collider make_rect(const RectI& rect);
static Collider make_rect(const Recti& rect);
static Collider make_grid(int tile_size, int columns, int rows);
Shape shape() const;
RectI get_rect() const;
void set_rect(const RectI& value);
Recti get_rect() const;
void set_rect(const Recti& value);
bool get_cell(int x, int y) const;
void set_cell(int x, int y, bool value);
void set_cells(int x, int y, int w, int h, bool value);
@ -47,7 +47,7 @@ namespace TL
};
Shape m_shape = Shape::None;
RectI m_rect;
Recti m_rect;
Grid m_grid;
static bool rect_to_rect(const Collider* a, const Collider* b, Point offset);

View File

@ -44,7 +44,7 @@ void GhostFrog::update()
}
// flip sprite
anim->scale = Vec2(m_facing, 1);
anim->scale = Vec2f(m_facing, 1);
// NORMAL STATE
if (m_state == st_readying_attack)
@ -76,9 +76,9 @@ void GhostFrog::update()
if (Time::on_time(m_timer, 0.8f))
{
mover->speed.x = m_facing * 250;
hitbox->set_rect(RectI(-4 + m_facing * 4, -12, 8, 12));
hitbox->set_rect(Recti(-4 + m_facing * 4, -12, 8, 12));
RectI rect(8, -8, 20, 8);
Recti rect(8, -8, 20, 8);
if (m_facing < 0)
rect.x = -(rect.x + rect.w);
@ -97,7 +97,7 @@ void GhostFrog::update()
// end attack state
else if (m_timer >= anim->animation()->duration())
{
hitbox->set_rect(RectI(-4, -12, 8, 12));
hitbox->set_rect(Recti(-4, -12, 8, 12));
if (health > 0)
{
@ -107,7 +107,7 @@ void GhostFrog::update()
{
phase = 1;
health = max_health_2;
m_side = Calc::rand_int(0, 2) == 0 ? -1 : 1;
m_side = Game::rand_int(0, 2) == 0 ? -1 : 1;
set_state(st_floating);
}
}
@ -142,7 +142,7 @@ void GhostFrog::update()
// SHOOTING STATE
else if (m_state == st_shoot)
{
mover->speed = Calc::approach(mover->speed, Vec2::zero, 300 * Time::delta);
mover->speed = Vec2f::approach(mover->speed, Vec2f::zero, 300 * Time::delta);
m_facing = Calc::sign(player_x - x);
if (m_facing == 0)
@ -182,7 +182,7 @@ void GhostFrog::update()
{
if (m_reflect_count < 2)
{
if (Vec2(orb->entity()->position - orb->target()).length() < 16)
if (Vec2f(orb->entity()->position - orb->target()).length() < 16)
{
auto sign = Calc::sign(orb->entity()->position.x - x);
if (sign != 0)
@ -197,7 +197,7 @@ void GhostFrog::update()
}
else
{
if (Vec2(orb->entity()->position - orb->target()).length() < 8)
if (Vec2f(orb->entity()->position - orb->target()).length() < 8)
{
Factory::pop(world(), entity()->position + Point(0, -8));
orb->entity()->destroy();
@ -215,7 +215,7 @@ void GhostFrog::update()
if (Time::on_interval(0.25f))
{
auto offset = Point(Calc::rand_int(-16, 16), Calc::rand_int(-16, 16));
auto offset = Point(Game::rand_int(-16, 16), Game::rand_int(-16, 16));
Factory::pop(world(), entity()->position + Point(0, -8) + offset);
}

View File

@ -11,11 +11,11 @@ namespace TL
class Mover : public Component
{
private:
Vec2 m_remainder;
Vec2f m_remainder;
public:
Collider* collider = nullptr;
Vec2 speed;
Vec2f speed;
float gravity = 0;
float friction = 0;
std::function<void(Mover*)> on_hit_x;

View File

@ -24,38 +24,37 @@ namespace
Player::Player()
{
input_move.add_dpad(0);
input_move.add_left_stick(0, 0.2f);
input_move.add(Key::Left, Key::Right, Key::Up, Key::Down);
input_move = Input::register_binding(StickBinding());
input_move->add_dpad(0);
input_move->add_left_stick(0, 0.2f);
input_move->add(Key::Left, Key::Right, Key::Up, Key::Down);
input_jump.press_buffer = 0.15f;
input_jump.add(Key::X, Button::A);
input_jump = Input::register_binding(ButtonBinding());
input_jump->press_buffer = 0.15f;
input_jump->add(Key::X, Button::A);
input_attack.press_buffer = 0.15f;
input_attack.add(Key::C, Button::X);
input_attack = Input::register_binding(ButtonBinding());
input_attack->press_buffer = 0.15f;
input_attack->add(Key::C, Button::X);
}
void Player::update()
{
input_move.update();
input_jump.update();
input_attack.update();
auto mover = get<Mover>();
auto anim = get<Animator>();
auto hitbox = get<Collider>();
auto was_on_ground = m_on_ground;
m_on_ground = mover->on_ground();
int input = input_move.sign().x;
int input = input_move->sign().x;
// Sprite Stuff
{
// land squish
if (!was_on_ground && m_on_ground)
anim->scale = Vec2(m_facing * 1.5f, 0.7f);
anim->scale = Vec2f(m_facing * 1.5f, 0.7f);
// lerp scale back to one
anim->scale = Calc::approach(anim->scale, Vec2(m_facing, 1.0f), Time::delta * 4);
anim->scale = Vec2f::approach(anim->scale, Vec2f(m_facing, 1.0f), Time::delta * 4);
// set m_facing
anim->scale.x = Calc::abs(anim->scale.x) * m_facing;
@ -114,25 +113,25 @@ void Player::update()
// Invoke Jumping
{
if (input_jump.pressed() && mover->on_ground())
if (input_jump->pressed() && mover->on_ground())
{
input_jump.consume_press();
anim->scale = Vec2(m_facing * 0.65f, 1.4f);
input_jump->consume_press();
anim->scale = Vec2f(m_facing * 0.65f, 1.4f);
mover->speed.x = input * max_air_speed;
m_jump_timer = jump_time;
}
}
// Begin Attack
if (input_attack.pressed())
if (input_attack->pressed())
{
input_attack.consume_press();
input_attack->consume_press();
m_state = st_attack;
m_attack_timer = 0;
if (!m_attack_collider)
m_attack_collider = entity()->add(Collider::make_rect(RectI()));
m_attack_collider = entity()->add(Collider::make_rect(Recti()));
m_attack_collider->mask = Mask::player_attack;
if (m_on_ground)
@ -148,11 +147,11 @@ void Player::update()
// setup hitbox
if (m_attack_timer < 0.2f)
{
m_attack_collider->set_rect(RectI(-16, -12, 16, 8));
m_attack_collider->set_rect(Recti(-16, -12, 16, 8));
}
else if (m_attack_timer < 0.5f)
{
m_attack_collider->set_rect(RectI(8, -8, 16, 8));
m_attack_collider->set_rect(Recti(8, -8, 16, 8));
}
else if (m_attack_collider)
{
@ -190,7 +189,7 @@ void Player::update()
{
mover->speed.y = -100;
m_jump_timer -= Time::delta;
if (!input_jump.down())
if (!input_jump->down())
m_jump_timer = 0;
}
@ -209,7 +208,7 @@ void Player::update()
if (!m_on_ground)
{
float grav = gravity;
if (m_state == st_normal && Calc::abs(mover->speed.y) < 20 && input_jump.down())
if (m_state == st_normal && Calc::abs(mover->speed.y) < 20 && input_jump->down())
grav *= 0.4f;
mover->speed.y += grav * Time::delta;
@ -230,7 +229,7 @@ void Player::update()
m_attack_collider = nullptr;
}
mover->speed = Vec2(-m_facing * 100, -80);
mover->speed = Vec2f(-m_facing * 100, -80);
health--;
m_hurt_timer = hurt_duration;

View File

@ -18,9 +18,9 @@ namespace TL
int health = max_health;
StickBinding input_move;
Binding input_jump;
Binding input_attack;
StickBindingRef input_move;
ButtonBindingRef input_jump;
ButtonBindingRef input_attack;
Player();
void update() override;

View File

@ -52,12 +52,12 @@ void Tilemap::set_cells(int x, int y, int w, int h, const Subtexture* tex)
void Tilemap::render(Batch& batch)
{
batch.push_matrix(Mat3x2::create_translation(entity()->position));
batch.push_matrix(Mat3x2f::create_translation(entity()->position));
for (int x = 0; x < m_columns; x ++)
for (int y = 0; y < m_rows; y ++)
if (m_grid[x + y * m_columns].texture)
{
batch.tex(m_grid[x + y * m_columns], Vec2(x * m_tile_width, y * m_tile_height));
batch.tex(m_grid[x + y * m_columns], Vec2f(x * m_tile_width, y * m_tile_height));
}
batch.pop_matrix();
}

View File

@ -43,7 +43,10 @@ FilePath Content::path()
} while (!Directory::exists(root) && up.length() < 30);
if (!Directory::exists(root))
BLAH_ERROR("Unable to find content directory!");
{
Log::error("Unable to find content directory!");
return "";
}
Log::info("Content Path: %s", root.cstr());
}
@ -105,7 +108,7 @@ void Content::load()
for (int x = 0; x < columns; x++)
for (int y = 0; y < rows; y++)
{
auto subrect = RectI(x * Game::tile_width, y * Game::tile_height, Game::tile_width, Game::tile_height);
auto subrect = Recti(x * Game::tile_width, y * Game::tile_height, Game::tile_width, Game::tile_height);
auto subimage = frame.image.get_sub_image(subrect);
packer.add(pack_index, subimage);
pack_index++;
@ -128,11 +131,11 @@ void Content::load()
{
Sprite sprite;
sprite.name = info.name;
sprite.origin = Vec2::zero;
sprite.origin = Vec2f::zero;
if (info.aseprite.slices.size() > 0 && info.aseprite.slices[0].has_pivot)
{
sprite.origin = Vec2(
sprite.origin = Vec2f(
info.aseprite.slices[0].pivot.x,
info.aseprite.slices[0].pivot.y);
}
@ -199,7 +202,7 @@ void Content::load()
void Content::unload()
{
font.dispose();
font = SpriteFont();
}
TextureRef Content::atlas()

View File

@ -20,7 +20,7 @@ Entity* Factory::player(World* world, Point position)
anim->play("idle");
anim->depth = -10;
auto hitbox = en->add(Collider::make_rect(RectI(-4, -12, 8, 12)));
auto hitbox = en->add(Collider::make_rect(Recti(-4, -12, 8, 12)));
hitbox->mask = Mask::player;
auto mover = en->add(Mover());
@ -38,7 +38,7 @@ Entity* Factory::bramble(World* world, Point position)
anim->play("idle");
anim->depth = -5;
auto hitbox = en->add(Collider::make_rect(RectI(-4, -8, 8, 8)));
auto hitbox = en->add(Collider::make_rect(Recti(-4, -8, 8, 8)));
hitbox->mask = Mask::enemy;
auto hurtable = en->add(Hurtable());
@ -78,7 +78,7 @@ Entity* Factory::spitter(World* world, Point position)
anim->play("idle");
anim->depth = -5;
auto hitbox = en->add(Collider::make_rect(RectI(-6, -12, 12, 12)));
auto hitbox = en->add(Collider::make_rect(Recti(-6, -12, 12, 12)));
hitbox->mask = Mask::enemy;
auto hurtable = en->add(Hurtable());
@ -110,12 +110,12 @@ Entity* Factory::bullet(World* world, Point position, int direction)
anim->play("idle");
anim->depth = -5;
auto hitbox = en->add(Collider::make_rect(RectI(-4, -4, 8, 8)));
auto hitbox = en->add(Collider::make_rect(Recti(-4, -4, 8, 8)));
hitbox->mask = Mask::enemy;
auto mover = en->add(Mover());
mover->collider = hitbox;
mover->speed = Vec2(direction * 40, 0);
mover->speed = Vec2f(direction * 40, 0);
mover->gravity = 130;
mover->on_hit_x = [](Mover* self) { self->entity()->destroy(); };
mover->on_hit_y = [](Mover* self) { self->speed.y = -60; };
@ -203,7 +203,7 @@ Entity* Factory::mosquito(World* world, Point position)
anim->play("fly");
anim->depth = -5;
auto hitbox = en->add(Collider::make_rect(RectI(-4, -4, 8, 8)));
auto hitbox = en->add(Collider::make_rect(Recti(-4, -4, 8, 8)));
hitbox->mask = Mask::enemy;
auto mover = en->add(Mover());
@ -225,7 +225,7 @@ namespace
anim->play("idle");
anim->depth = -1;
auto hitbox = en->add(Collider::make_rect(RectI(-6, -16, 12, 16)));
auto hitbox = en->add(Collider::make_rect(Recti(-6, -16, 12, 16)));
hitbox->mask = Mask::solid;
}
}
@ -275,7 +275,7 @@ Entity* Factory::blob(World* world, Point position)
anim->play("idle");
anim->depth = -5;
auto hitbox = en->add(Collider::make_rect(RectI(-4, -8, 8, 8)));
auto hitbox = en->add(Collider::make_rect(Recti(-4, -8, 8, 8)));
hitbox->mask = Mask::enemy;
auto mover = en->add(Mover());
@ -307,7 +307,7 @@ Entity* Factory::blob(World* world, Point position)
auto dir = Calc::sign(player->entity()->position.x - self->entity()->position.x);
if (dir == 0) dir = 1;
self->get<Animator>()->scale = Vec2(dir, 1);
self->get<Animator>()->scale = Vec2f(dir, 1);
mover->speed.x = dir * 40;
}
}
@ -347,7 +347,7 @@ Entity* Factory::ghost_frog(World* world, Point position)
anim->play("sword");
anim->depth = -5;
auto hitbox = en->add(Collider::make_rect(RectI(-4, -12, 8, 12)));
auto hitbox = en->add(Collider::make_rect(Recti(-4, -12, 8, 12)));
hitbox->mask = Mask::enemy;
auto mover = en->add(Mover());
@ -374,7 +374,7 @@ Entity* Factory::orb(World* world, Point position)
anim->play("idle");
anim->depth = -5;
auto hitbox = en->add(Collider::make_rect(RectI(-4, -4, 8, 8)));
auto hitbox = en->add(Collider::make_rect(Recti(-4, -4, 8, 8)));
hitbox->mask = Mask::enemy;
auto mover = en->add(Mover());
@ -384,7 +384,7 @@ Entity* Factory::orb(World* world, Point position)
auto hurtable = en->add(Hurtable());
hurtable->hurt_by = Mask::player_attack;
hurtable->collider = en->add(Collider::make_rect(RectI(-8, -8, 16, 16)));
hurtable->collider = en->add(Collider::make_rect(Recti(-8, -8, 16, 16)));
hurtable->on_hurt = [](Hurtable* self) { self->get<Orb>()->on_hit(); };
return en;

View File

@ -8,6 +8,7 @@
#include "components/mover.h"
#include "assets/sprite.h"
#include "factory.h"
#include <cstdlib>
using namespace TL;
@ -24,7 +25,7 @@ void Game::startup()
Content::load();
// framebuffer for the game
buffer = FrameBuffer::create(width, height);
buffer = Target::create(width, height);
// set batcher to use Nearest Filter
batch.default_sampler = TextureSampler(TextureFilter::Nearest);
@ -32,7 +33,7 @@ void Game::startup()
// load first room
load_room(Point(0, 0));
camera = Vec2(room.x * width, room.y * height);
camera = Vec2f(room.x * width, room.y * height);
fullscreen = false;
}
@ -102,7 +103,7 @@ void Game::load_room(Point cell, bool is_reload)
{
tilemap->set_cell(x, y, &jumpthrus->random_tile());
auto jumpthru_en = world.add_entity(offset + Point(x * tile_width, y * tile_height));
auto jumpthru_col = jumpthru_en->add(Collider::make_rect(RectI(0, 0, 8, 4)));
auto jumpthru_col = jumpthru_en->add(Collider::make_rect(Recti(0, 0, 8, 4)));
jumpthru_col->mask = Mask::jumpthru;
break;
}
@ -176,6 +177,7 @@ void Game::update()
m_transition = false;
world.clear();
load_room(Point(0, 0));
camera = Vec2f(0, 0);
}
// Toggle Fullscreen
@ -191,8 +193,8 @@ void Game::update()
{
if (Time::on_interval(0.05f))
{
m_shake.x = Calc::rand_int(0, 2) == 0 ? -1 : 1;
m_shake.y = Calc::rand_int(0, 2) == 0 ? -1 : 1;
m_shake.x = rand_int(0, 2) == 0 ? -1 : 1;
m_shake.y = rand_int(0, 2) == 0 ? -1 : 1;
}
}
else
@ -206,7 +208,7 @@ void Game::update()
if (player)
{
auto pos = player->entity()->position;
auto bounds = RectI(room.x * width, room.y * height, width, height);
auto bounds = Recti(room.x * width, room.y * height, width, height);
if (!bounds.contains(pos))
{
// target room
@ -275,8 +277,8 @@ void Game::update()
m_next_ease = Calc::approach(m_next_ease, 1.0f, Time::delta / transition_duration);
// get last & next camera position
auto last_cam = Vec2(m_last_room.x * width, m_last_room.y * height);
auto next_cam = Vec2(m_next_room.x * width, m_next_room.y * height);
auto last_cam = Vec2f(m_last_room.x * width, m_last_room.y * height);
auto next_cam = Vec2f(m_next_room.x * width, m_next_room.y * height);
// LERP camera position
camera = last_cam + (next_cam - last_cam) * Ease::cube_in_out(m_next_ease);
@ -289,7 +291,7 @@ void Game::update()
{
auto player = world.first<Player>();
if (player)
player->get<Mover>()->speed = Vec2(0, -150);
player->get<Mover>()->speed = Vec2f(0, -150);
}
// delete old objects (except player!)
@ -312,7 +314,7 @@ void Game::render()
buffer->clear(0x150e22);
// push camera offset
batch.push_matrix(Mat3x2::create_translation(-camera + m_shake));
batch.push_matrix(Mat3x2f::create_translation(-camera + m_shake));
// draw gameplay objects
world.render(batch);
@ -381,17 +383,17 @@ void Game::render()
// draw buffer to the screen
{
float scale = Calc::min(
App::backbuffer->width() / (float)buffer->width(),
App::backbuffer->height() / (float)buffer->height());
App::backbuffer()->width() / (float)buffer->width(),
App::backbuffer()->height() / (float)buffer->height());
Vec2 screen_center = Vec2(App::backbuffer->width(), App::backbuffer->height()) / 2;
Vec2 buffer_center = Vec2(buffer->width(), buffer->height()) / 2;
Vec2f screen_center = Vec2f(App::backbuffer()->width(), App::backbuffer()->height()) / 2;
Vec2f buffer_center = Vec2f(buffer->width(), buffer->height()) / 2;
App::backbuffer->clear(Color::black);
batch.push_matrix(Mat3x2::create_transform(screen_center, buffer_center, Vec2::one * scale, 0));
batch.tex(buffer->attachment(0), Vec2::zero, Color::white);
App::backbuffer()->clear(Color::black);
batch.push_matrix(Mat3x2f::create_transform(screen_center, buffer_center, Vec2f::one * scale, 0));
batch.tex(buffer->texture(0), Vec2f::zero, Color::white);
batch.pop_matrix();
batch.render(App::backbuffer);
batch.render(App::backbuffer());
batch.clear();
}
}
@ -400,3 +402,8 @@ void Game::shake(float time)
{
m_shake_timer = time;
}
int Game::rand_int(int min, int max)
{
return min + (rand() % (max - min));
}

View File

@ -21,10 +21,10 @@ namespace TL
static inline const char* ending = "YOU SAVED POND\nAND YOU ARE\nA REAL HERO";
World world;
FrameBufferRef buffer;
TargetRef buffer;
Batch batch;
Point room;
Vec2 camera;
Vec2f camera;
bool fullscreen = false;
void load_room(Point cell, bool is_reload = false);
@ -34,6 +34,8 @@ namespace TL
void render();
void shake(float time);
static int rand_int(int min, int max);
private:
bool m_draw_colliders;
bool m_transition = false;

View File

@ -4,42 +4,19 @@
using namespace Blah;
using namespace TL;
namespace
int main()
{
Game game;
void startup()
{
game.startup();
}
void shutdown()
{
game.shutdown();
}
void update()
{
game.update();
}
void render()
{
game.render();
}
}
int main()
{
Config config;
config.name = "Sword II: Adventure of Frog";
config.width = 1280;
config.height = 720;
config.on_startup = startup;
config.on_shutdown = shutdown;
config.on_update = update;
config.on_render = render;
config.on_startup = [&]() { game.startup(); };
config.on_shutdown = [&]() { game.shutdown(); };
config.on_update = [&]() { game.update(); };
config.on_render = [&]() { game.render(); };
App::run(&config);
}