#pragma once

#include "demo/scene.hpp"
#include "demo/lizard/world.hpp"

namespace demo {

  struct lizard : scene {
    world::level * current_level;
    world::platform * last_platform1;
    world::platform * last_platform;
    world::platform * end_platform;
    vec3 lizard_position;
    vec3 lizard_velocity;
    float lizard_heading;
    float lizard_rotation;
    float lizard_walking_frame;
    float lizard_turning_frame;
    int platform_touch_count;
    int y_press_count;
    int end_platform_tick;
    int total_tick;
    bool button_press;

    int last_cover_texture_offset;
    float cover_ix_transition;

    int emulator_detected_hud_frames;
    bool collided;

    mat4x4 view_trans;

    float vx;
    float vy;

    mat4x4 init() override;

    void update() override;

    void y() override;
    void x() override;
    void b() override;
    void a() override;

    void ra() override;
    void la() override;
    void ua() override;
    void da() override;

    void start() override;

    void analog(float dl, float dr, float dx, float dy) override;

    world::platform * lizard_collide();

    void draw_hud(ta_parameter_writer& writer);
    void draw_platform(ta_parameter_writer& writer, const mat4x4& trans, const world::platform * p);
    void draw_lizard(ta_parameter_writer& writer, const mat4x4& trans);
    void draw_cover(ta_parameter_writer& writer, const mat4x4& trans);
    void draw(ta_parameter_writer& writer, const mat4x4& trans) override;
  };
}
