2018-10-17 23:21:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <charcoal/Poseable.h>
|
|
|
|
#include <charcoal/Scene.h>
|
|
|
|
#include <charcoal-builtin/BuiltinCamera2D.h>
|
|
|
|
#include <charcoal-builtin/BasicPipeline.h>
|
|
|
|
|
|
|
|
using namespace charcoal;
|
|
|
|
using namespace charcoal::builtin;
|
|
|
|
|
|
|
|
class MyPongScene : public Scene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyPongScene(Application& application);
|
|
|
|
|
|
|
|
void init() override;
|
|
|
|
|
|
|
|
void use() override {}
|
|
|
|
|
|
|
|
void unuse() override {}
|
|
|
|
|
|
|
|
void update(float delta_time, clock_t clock) override;
|
|
|
|
|
|
|
|
void prerender() override;
|
|
|
|
|
|
|
|
void render() override;
|
|
|
|
|
|
|
|
private:
|
2018-10-18 04:48:05 +00:00
|
|
|
float random();
|
|
|
|
|
|
|
|
vec2 rand_dir(float radians_low, float radians_high);
|
|
|
|
|
|
|
|
void reset_ball();
|
|
|
|
|
2018-10-17 23:21:58 +00:00
|
|
|
basic::Renderable m_outline_column;
|
|
|
|
basic::Renderable m_outline_row;
|
|
|
|
basic::Renderable m_ball;
|
2018-10-18 04:48:05 +00:00
|
|
|
basic::Renderable m_life;
|
2018-10-17 23:21:58 +00:00
|
|
|
basic::Renderable m_paddle;
|
|
|
|
|
|
|
|
basic::Batch m_outline_column_batch;
|
|
|
|
basic::Batch m_outline_row_batch;
|
|
|
|
basic::Batch m_ball_batch;
|
2018-10-18 04:48:05 +00:00
|
|
|
basic::Batch m_life_batch;
|
2018-10-17 23:21:58 +00:00
|
|
|
basic::Batch m_paddle_batch;
|
|
|
|
|
|
|
|
Poseable m_outline_top_pose;
|
|
|
|
Poseable m_outline_bottom_pose;
|
|
|
|
Poseable m_outline_left_pose;
|
|
|
|
Poseable m_outline_right_pose;
|
|
|
|
|
|
|
|
Poseable m_ball_pose;
|
|
|
|
Poseable m_paddle_left_pose;
|
|
|
|
Poseable m_paddle_right_pose;
|
|
|
|
|
|
|
|
builtin::Camera2D m_camera;
|
|
|
|
basic::Pipeline m_pipeline;
|
|
|
|
|
|
|
|
float m_ball_speed;
|
|
|
|
glm::vec2 m_ball_direction;
|
2018-10-18 04:48:05 +00:00
|
|
|
|
|
|
|
int m_left_lives;
|
|
|
|
int m_right_lives;
|
2018-10-17 23:21:58 +00:00
|
|
|
};
|