generated from Laguna1989/JamTemplateCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b84f112
commit dfb3ec8
Showing
23 changed files
with
129 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "platform.hpp" | ||
|
||
Platform::Platform(std::shared_ptr<jt::Box2DWorldInterface> world, b2BodyDef const* def, | ||
jt::Vector2f const& pos, jt::Vector2f const& size) | ||
: Box2DObject(world, def) | ||
{ | ||
m_size = size; | ||
|
||
b2FixtureDef fixtureDef; | ||
b2PolygonShape boxCollider {}; | ||
boxCollider.SetAsBox(size.x / 2.0f, size.y / 2.0f); | ||
fixtureDef.shape = &boxCollider; | ||
getB2Body()->CreateFixture(&fixtureDef); | ||
|
||
setPosition(pos); | ||
} | ||
|
||
void Platform::doCreate() | ||
{ | ||
m_shape = std::make_shared<jt::Shape>(); | ||
m_shape->makeRect(m_size, textureManager()); | ||
m_shape->setOffset(jt::OffsetMode::CENTER); | ||
} | ||
|
||
void Platform::doUpdate(float const elapsed) | ||
{ | ||
m_shape->setPosition(getPosition()); | ||
m_shape->update(elapsed); | ||
} | ||
void Platform::doDraw() const { m_shape->draw(renderTarget()); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef INC_1HGJ384_PLATFORM_HPP | ||
#define INC_1HGJ384_PLATFORM_HPP | ||
|
||
#include <box2dwrapper/box2d_object.hpp> | ||
#include <shape.hpp> | ||
|
||
class Platform : public jt::Box2DObject { | ||
public: | ||
Platform(std::shared_ptr<jt::Box2DWorldInterface> world, b2BodyDef const* def, | ||
jt::Vector2f const& pos, jt::Vector2f const& size); | ||
|
||
private: | ||
std::shared_ptr<jt::Shape> m_shape; | ||
|
||
jt::Vector2f m_size; | ||
|
||
void doCreate() override; | ||
void doUpdate(float const elapsed) override; | ||
void doDraw() const override; | ||
}; | ||
|
||
#endif // INC_1HGJ384_PLATFORM_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "player.hpp" | ||
#include <game_interface.hpp> | ||
|
||
Player::Player(std::shared_ptr<jt::Box2DWorldInterface> world, b2BodyDef const* def) | ||
: Box2DObject(world, def) | ||
{ | ||
b2FixtureDef fixtureDef; | ||
b2PolygonShape boxCollider {}; | ||
boxCollider.SetAsBox(8, 24); | ||
fixtureDef.shape = &boxCollider; | ||
getB2Body()->CreateFixture(&fixtureDef); | ||
|
||
setPosition(jt::Vector2f { 50.0f, 50.0f }); | ||
} | ||
|
||
void Player::doCreate() | ||
{ | ||
m_shape = std::make_shared<jt::Shape>(); | ||
m_shape->makeRect(jt::Vector2f { 16, 48 }, textureManager()); | ||
m_shape->setOffset(jt::OffsetMode::CENTER); | ||
} | ||
|
||
void Player::doUpdate(float const elapsed) | ||
{ | ||
|
||
auto& input = getGame()->input(); | ||
if (input.keyboard()->pressed(jt::KeyCode::D)) { | ||
getB2Body()->ApplyForceToCenter(b2Vec2 { 100.0f, 0.0f }, true); | ||
} else if (input.keyboard()->pressed(jt::KeyCode::A)) { | ||
getB2Body()->ApplyForceToCenter(b2Vec2 { -100.0f, 0.0f }, true); | ||
} | ||
|
||
m_shape->setPosition(getPosition()); | ||
m_shape->update(elapsed); | ||
} | ||
|
||
void Player::doDraw() const { m_shape->draw(renderTarget()); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef INC_1HGJ384_PLAYER_HPP | ||
#define INC_1HGJ384_PLAYER_HPP | ||
|
||
#include <box2dwrapper/box2d_object.hpp> | ||
#include <shape.hpp> | ||
|
||
class Player : public jt::Box2DObject { | ||
public: | ||
Player(std::shared_ptr<jt::Box2DWorldInterface> world, b2BodyDef const* def); | ||
|
||
private: | ||
std::shared_ptr<jt::Shape> m_shape; | ||
|
||
void doCreate() override; | ||
void doUpdate(float const elapsed) override; | ||
void doDraw() const override; | ||
}; | ||
|
||
#endif // INC_1HGJ384_PLAYER_HPP |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
impl/gamelib/player/graphics/graphics_component_interface.hpp
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.