Skip to content

Instantly share code, notes, and snippets.

@ldunn
Created January 8, 2011 02:52
Show Gist options
  • Save ldunn/770485 to your computer and use it in GitHub Desktop.
Save ldunn/770485 to your computer and use it in GitHub Desktop.
#pragma once
#ifndef ENTITY_H
#define ENTITY_H
#include "vector3.h"
class Entity
{
public:
Vector3 Pos;
Vector3 Rotation;
Vector3 Hitbox; // Width, height, depth
virtual void Render();
Entity(Vector3 initpos, Vector3 initrotation, Vector3 inithitbox);
};
#endif
#include "player.h"
#include <cmath>
const double PI = 3.14159265358979323846264338329750288419716939937510582;
Player::Player() : Speed(0), Rotation(Vector3(0,0,0)), Pos(Vector3(0,0,0)), Moving(false), Name("Untitled"), StandingOn(NULL), GravitySpeed(0.f), SurfaceZ(0.f) {};
Player::Player(float initspeed, Vector3 initrot, Vector3 initpos, std::string Name) : Speed(initspeed), Rotation(initrot), Pos(initpos), Moving(false), Name(Name), StandingOn(NULL), GravitySpeed(0.f), SurfaceZ(0.f) {};
#pragma once
#ifndef PLAYER_H
#define PLAYER_H
#include <string>
#include "octree.h"
#include "block.h"
#include "entity.h"
#include "vector3.h"
class Player : public Entity
{
public:
float Speed;
bool Moving;
std::string Name;
Octree<Block*> *StandingOn;
float SurfaceZ;
float GravitySpeed;
Player();
Player(float initspeed, Vector3 initrot, Vector3 initpos, std::string Name);
// Moves the player around
void Forward(float amount);
void Strafe(float amount);
void ChangeRotation(float deltaYrot, float deltaZrot);
void Jump(); // Begins a jump
void DoStep(float amount); // Gets called every frame
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment