added defaultKeysMap instead of myKeysMap
This commit is contained in:
parent
ebb77b7470
commit
fa03256a48
6
src/defaultkeysmap.cpp
Normal file
6
src/defaultkeysmap.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "defaultkeysmap.h"
|
||||
|
||||
//DefaultKeysMap::DefaultKeysMap()
|
||||
//{
|
||||
|
||||
//}
|
42
src/defaultkeysmap.h
Normal file
42
src/defaultkeysmap.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef DEFAULTKEYSMAP_H
|
||||
#define DEFAULTKEYSMAP_H
|
||||
|
||||
#include "keybindings.h"
|
||||
|
||||
class DefaultKeysMap : public IKeysMap
|
||||
{
|
||||
public:
|
||||
enum{MAIN_ACTION, SECONDARY_ACTION, MOVE_FORWARD, MOVE_BACKWARD, STRAFE_LEFT, STRAFE_RIGHT,
|
||||
TOGGLE_NOCLIP, TOGGLE_PHYSICS_DEBUG, TOGGLE_CONSOLE,
|
||||
MOVE_CURSOR_LEFT, MOVE_CURSOR_RIGHT, PLOP_TEST, CLEAR_CONSOLE,
|
||||
EXIT_GAME,LAST_DEFAULT_ACTION};
|
||||
|
||||
DefaultKeysMap(){
|
||||
keys.push_back( {MAIN_ACTION, sf::Keyboard::KeyCount + sf::Mouse::Left, IKeysMap::PRESSED} );
|
||||
keys.push_back( {SECONDARY_ACTION, sf::Keyboard::KeyCount + sf::Mouse::Right, IKeysMap::PRESSED} );
|
||||
keys.push_back( {MOVE_FORWARD, sf::Keyboard::Z, IKeysMap::HOLD} );
|
||||
keys.push_back( {MOVE_BACKWARD, sf::Keyboard::S, IKeysMap::HOLD} );
|
||||
keys.push_back( {STRAFE_LEFT, sf::Keyboard::Q, IKeysMap::HOLD} );
|
||||
keys.push_back( {STRAFE_RIGHT, sf::Keyboard::D, IKeysMap::HOLD} );
|
||||
keys.push_back( {TOGGLE_NOCLIP, sf::Keyboard::G, IKeysMap::PRESSED} );
|
||||
keys.push_back( {TOGGLE_PHYSICS_DEBUG, sf::Keyboard::P, IKeysMap::PRESSED} );
|
||||
keys.push_back( {TOGGLE_CONSOLE, sf::Keyboard::F3, IKeysMap::PRESSED} );
|
||||
keys.push_back( {MOVE_CURSOR_LEFT, sf::Keyboard::Left, IKeysMap::PRESSED} );
|
||||
keys.push_back( {MOVE_CURSOR_RIGHT, sf::Keyboard::Right, IKeysMap::PRESSED} );
|
||||
keys.push_back( {PLOP_TEST, sf::Keyboard::F7, IKeysMap::PRESSED} );
|
||||
keys.push_back( {CLEAR_CONSOLE, sf::Keyboard::F2, IKeysMap::PRESSED} );
|
||||
keys.push_back( {EXIT_GAME, sf::Keyboard::Escape, IKeysMap::PRESSED} );
|
||||
}
|
||||
|
||||
static std::vector<int> getDefaultContext()
|
||||
{
|
||||
return {MAIN_ACTION, SECONDARY_ACTION, MOVE_FORWARD, MOVE_BACKWARD, STRAFE_LEFT, STRAFE_RIGHT, TOGGLE_NOCLIP, TOGGLE_PHYSICS_DEBUG, TOGGLE_CONSOLE, EXIT_GAME};
|
||||
}
|
||||
|
||||
static std::vector<int> getShellContext()
|
||||
{
|
||||
return {TOGGLE_CONSOLE,MOVE_CURSOR_LEFT,MOVE_CURSOR_RIGHT,PLOP_TEST,CLEAR_CONSOLE};
|
||||
}
|
||||
};
|
||||
|
||||
#endif // DEFAULTKEYSMAP_H
|
@ -44,6 +44,7 @@ public:
|
||||
sf::Window* getWindow() const {return m_window;}
|
||||
SparrowRenderer* getRenderer() const {return m_renderer;}
|
||||
btDiscreteDynamicsWorld* getPhysics() const {return m_world;}
|
||||
SparrowShell* getShell() const {return m_sparrowshell;}
|
||||
|
||||
void outputShell(std::string str) const;
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
#include "message.h"
|
||||
|
||||
|
||||
Message::Message(std::string id, SystemType sender):m_id(id),m_sender(sender)
|
||||
{
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef MESSAGE_H
|
||||
#define MESSAGE_H
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "system.h"
|
||||
|
||||
class Message
|
||||
{
|
||||
std::string m_id;
|
||||
SystemType m_sender;
|
||||
public:
|
||||
Message(std::string,SystemType);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // MESSAGE_H
|
@ -1,29 +0,0 @@
|
||||
#include "messagebus.h"
|
||||
#include "system.h"
|
||||
|
||||
MessageBus::MessageBus()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MessageBus::registerSystem(SystemType type, System* system){
|
||||
systems[type] = system;
|
||||
}
|
||||
|
||||
void MessageBus::update()
|
||||
{
|
||||
while (!message_list.empty()){
|
||||
Message* msg = message_list.front();
|
||||
message_list.pop();
|
||||
for(auto const &entity : systems){
|
||||
entity.second->handleMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessageBus::postMessage(Message *msg)
|
||||
{
|
||||
message_list.push(msg);
|
||||
}
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
#ifndef MESSAGEBUS_H
|
||||
#define MESSAGEBUS_H
|
||||
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "system.h"
|
||||
|
||||
class Message;
|
||||
class System;
|
||||
|
||||
class MessageBus
|
||||
{
|
||||
std::map<SystemType,System*> systems;
|
||||
std::queue<Message*> message_list; //message file
|
||||
|
||||
public:
|
||||
MessageBus();
|
||||
void registerSystem(SystemType,System*);
|
||||
void postMessage(Message* msg);
|
||||
void update();
|
||||
void handleMessage();
|
||||
};
|
||||
|
||||
#endif // MESSAGEBUS_H
|
11
src/sparrowshell/shellcontext.h
Normal file
11
src/sparrowshell/shellcontext.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef SHELLCONTEXT_H
|
||||
#define SHELLCONTEXT_H
|
||||
|
||||
class ShellContext : public Context
|
||||
{
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SHELLCONTEXT_H
|
@ -7,19 +7,30 @@
|
||||
#include <iostream>
|
||||
|
||||
|
||||
ShellScrollBar::ShellScrollBar(Mesh *mesh, SparrowShell *shell, glm::ivec2 dim):
|
||||
MeshNode(mesh,false), m_shell(shell),m_dimension(dim)
|
||||
ShellScrollBar::ShellScrollBar(SparrowShell *shell):
|
||||
MeshNode(nullptr,false), m_shell(shell)
|
||||
{
|
||||
m_position = glm::vec2(m_shell->getDimension().x-SparrowShell::SCROLLBAR_PIXEL_WIDTH,0);
|
||||
m_max_height = SparrowShell::DEFAULT_FONT_SIZE*SparrowShell::BUFFER_DISPLAYED_LINES;
|
||||
m_dimension = glm::vec2(SparrowShell::SCROLLBAR_PIXEL_WIDTH, m_max_height);
|
||||
moveTo2D(m_position);
|
||||
|
||||
Mesh* mesh = new Mesh();
|
||||
|
||||
mesh->addRectangle2D(glm::vec2(0),m_dimension);
|
||||
PhongMaterial* mat = new PhongMaterial();
|
||||
mat->diffuse = glm::vec3(0,0,0.5);
|
||||
mat->m_opacity = 0.8;
|
||||
mesh->setMaterial(mat);
|
||||
mesh->setDepth(SparrowShell::SHELL_DEPTH+1);
|
||||
mesh->initGL();
|
||||
m_geometry.mesh = mesh;
|
||||
}
|
||||
|
||||
void ShellScrollBar::update(){
|
||||
MeshNode::update();
|
||||
// m_position.y = m_shell->getPosition().y;
|
||||
// m_dimension.y = m_shell->getDimension().y;
|
||||
int size = m_shell->getBuffer()->size();
|
||||
float cran = ((float)m_shell->getDimension().y/(float)size);
|
||||
float cran = (m_max_height/(float)size);
|
||||
int indexCursor = size - (m_shell->getIndex()+SparrowShell::BUFFER_DISPLAYED_LINES);
|
||||
|
||||
if (m_shell->isBufferResized()){
|
||||
|
@ -9,10 +9,16 @@ class SparrowShell;
|
||||
class ShellScrollBar : public MeshNode
|
||||
{
|
||||
SparrowShell* m_shell;
|
||||
float m_max_height;
|
||||
glm::ivec2 m_position;
|
||||
glm::ivec2 m_dimension;
|
||||
|
||||
glm::vec3 m_color;
|
||||
public:
|
||||
ShellScrollBar(Mesh* mesh, SparrowShell* shell, glm::ivec2 dim);
|
||||
ShellScrollBar(SparrowShell* shell);
|
||||
void update();
|
||||
|
||||
void setColor(glm::vec3 color){m_color = color;}
|
||||
|
||||
};
|
||||
#endif // SHELLSCROLLBAR_H
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "sparrowshell.h"
|
||||
|
||||
//#include "message.h"
|
||||
#include "input.h"
|
||||
#include "scene/scenetree.h"
|
||||
#include "scene/meshnode.h"
|
||||
@ -23,8 +22,8 @@ SparrowShell::SparrowShell(sf::Window* window):
|
||||
m_position(glm::ivec2(0)),
|
||||
m_buffer(new ShellBuffer(BUFFER_MAX_LENGTH)),
|
||||
m_text_color(glm::vec3(0.7,1,0.3)),
|
||||
m_input_mesh(nullptr),
|
||||
m_input_cursor_pos(0)
|
||||
m_input_cursor_pos(0),
|
||||
m_input_mesh(nullptr)
|
||||
{
|
||||
sf::Vector2u size = window->getSize();
|
||||
m_dimension = glm::ivec2(size.x,DEFAULT_FONT_SIZE*(BUFFER_DISPLAYED_LINES+1));
|
||||
@ -47,27 +46,23 @@ SparrowShell::SparrowShell(sf::Window* window):
|
||||
m_background = new MeshNode(mesh,false);
|
||||
|
||||
//Create mesh for scrollbar
|
||||
mesh = new Mesh();
|
||||
glm::vec2 shell_pos = glm::vec2(0,0);
|
||||
glm::vec2 shell_dim = glm::vec2(SCROLLBAR_PIXEL_WIDTH,DEFAULT_FONT_SIZE*BUFFER_DISPLAYED_LINES);
|
||||
mesh->addRectangle2D(shell_pos,shell_dim);
|
||||
mat = new PhongMaterial();
|
||||
mat->diffuse = glm::vec3(0,0,0.5);
|
||||
mat->m_opacity = 0.8;
|
||||
mesh->setMaterial(mat);
|
||||
mesh->setDepth(SHELL_DEPTH+1);
|
||||
mesh->initGL();
|
||||
m_scrollbar = new ShellScrollBar(mesh,this,shell_dim);
|
||||
m_scrollbar = new ShellScrollBar(this);
|
||||
|
||||
this->addChild(m_background);
|
||||
this->addChild(m_buffer);
|
||||
this->addChild(m_scrollbar);
|
||||
}
|
||||
|
||||
void SparrowShell::out(std::string s)
|
||||
// write string str in shell
|
||||
void SparrowShell::out(std::string str)
|
||||
{
|
||||
out(str,m_text_color);
|
||||
}
|
||||
|
||||
void SparrowShell::out(std::string str,glm::vec3 color)
|
||||
{
|
||||
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
||||
TextNode* tnode = shellfont->getTextNode(s,m_text_color,m_buffer->getFontSize(),false);
|
||||
TextNode* tnode = shellfont->getTextNode(str,color,m_buffer->getFontSize(),false);
|
||||
tnode->setDepth(SHELL_DEPTH+1);
|
||||
m_buffer->push(tnode);
|
||||
if (m_buffer->size() > SparrowShell::BUFFER_DISPLAYED_LINES)
|
||||
@ -92,6 +87,14 @@ void SparrowShell::scrollDown()
|
||||
|
||||
void SparrowShell::toggleShell()
|
||||
{
|
||||
if(m_shellEnabled){
|
||||
getEngine().getInput()->setCurrentContext(m_previous_context);
|
||||
getEngine().getWindow()->setKeyRepeatEnabled(false);
|
||||
}else{
|
||||
m_previous_context = getEngine().getInput()->getCurrentContext();
|
||||
getEngine().getInput()->setCurrentContext("shell");
|
||||
getEngine().getWindow()->setKeyRepeatEnabled(true);
|
||||
}
|
||||
m_shellEnabled = !m_shellEnabled;
|
||||
for(auto child : m_children)
|
||||
child->toggleVisibility();
|
||||
@ -103,13 +106,20 @@ void SparrowShell::update()
|
||||
{
|
||||
m_resizeBuffer = false;
|
||||
m_indexMoved = false;
|
||||
auto input = getEngine().getInput();
|
||||
for(auto action : input->getActions()){
|
||||
if(action == 6){
|
||||
out("Plop");
|
||||
}
|
||||
}
|
||||
if(m_shellEnabled){
|
||||
auto input = getEngine().getInput();
|
||||
for(auto action : input->getActions()){
|
||||
if(action == m_plop_test){
|
||||
out("Plop");
|
||||
}else if (action == m_move_cursor_left){
|
||||
if (m_input_cursor_pos > 0)
|
||||
moveCursorLeft();
|
||||
}
|
||||
else if(action == m_move_cursor_right){
|
||||
if(m_input_cursor_pos < m_input_string.length())
|
||||
moveCursorRight();
|
||||
}
|
||||
}
|
||||
updateTextInput();
|
||||
int scroll = input->getDeltaVerticalScroll();
|
||||
if(scroll > 0)
|
||||
@ -125,18 +135,35 @@ void SparrowShell::updateTextInput()
|
||||
std::string text = getEngine().getInput()->getText();
|
||||
for(unsigned int i = 0 ; i < text.length() ; i++){
|
||||
char c = text[i];
|
||||
if (c == 8){
|
||||
switch(c){
|
||||
case 8:
|
||||
if(m_input_cursor_pos > 0)
|
||||
m_input_string.erase(--m_input_cursor_pos,1);
|
||||
}else
|
||||
break;
|
||||
case 13:
|
||||
if (m_input_string != ""){
|
||||
out(m_input_string);
|
||||
//DIMITRI : Take m_input_string here and send it to LUA :D
|
||||
}
|
||||
m_input_string.clear();
|
||||
m_input_cursor_pos = 0;
|
||||
break;
|
||||
default:
|
||||
m_input_string.insert(m_input_cursor_pos++,std::string(1,c));
|
||||
std::cout << text[i] << (int) text[i] << std::endl;
|
||||
}
|
||||
|
||||
// if (c == 8){
|
||||
// if(m_input_cursor_pos > 0)
|
||||
// m_input_string.erase(--m_input_cursor_pos,1);
|
||||
// }else
|
||||
// m_input_string.insert(m_input_cursor_pos++,std::string(1,c));
|
||||
// std::cout << text[i] << (int) text[i] << std::endl;
|
||||
}
|
||||
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
||||
if(m_input_mesh)
|
||||
this->removeChild(m_input_mesh);
|
||||
if(m_input_string != "")
|
||||
{
|
||||
if(m_input_mesh)
|
||||
this->removeChild(m_input_mesh);
|
||||
m_input_mesh = shellfont->getTextNode(m_input_string,m_text_color,m_buffer->getFontSize(),false);
|
||||
m_input_mesh->moveTo2D(glm::vec2(0,m_buffer->getFontSize()*BUFFER_DISPLAYED_LINES));
|
||||
this->addChild(m_input_mesh);
|
||||
|
@ -3,12 +3,12 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "system.h"
|
||||
#include "scene/scenetree.h"
|
||||
#include "glm/vec2.hpp"
|
||||
#include "sparrowshell/shellbuffer.h"
|
||||
#include "sparrowshell/shellscrollbar.h"
|
||||
#include "scene/graphicalcontainernode.h"
|
||||
#include "keybindings.h"
|
||||
|
||||
class Input;
|
||||
class MeshNode;
|
||||
@ -34,9 +34,15 @@ private:
|
||||
|
||||
glm::vec3 m_text_color;
|
||||
std::string m_input_string;
|
||||
int m_input_cursor_pos;
|
||||
unsigned int m_input_cursor_pos;
|
||||
TextNode* m_input_mesh;
|
||||
|
||||
int m_plop_test;
|
||||
int m_move_cursor_left;
|
||||
int m_move_cursor_right;
|
||||
int m_clear_console_action;
|
||||
std::string m_previous_context;
|
||||
|
||||
public:
|
||||
static const unsigned int BUFFER_MAX_LENGTH;
|
||||
static const unsigned int BUFFER_DISPLAYED_LINES;
|
||||
@ -52,7 +58,8 @@ public:
|
||||
void scrollDown();
|
||||
|
||||
void toggleShell();
|
||||
void out(std::string);
|
||||
void out(std::string str);
|
||||
void out(std::string str, glm::vec3 color);
|
||||
|
||||
glm::ivec2 getPosition(){return m_position;}
|
||||
glm::ivec2 getDimension(){return m_dimension;}
|
||||
@ -60,6 +67,14 @@ public:
|
||||
unsigned int getIndex(){return m_buffer->getIndex();}
|
||||
ShellBuffer* getBuffer(){return m_buffer;}
|
||||
|
||||
void setMoveCursorLeftAction(int action){m_move_cursor_left = action;}
|
||||
void setMoveCursorRightAction(int action){m_move_cursor_right = action;}
|
||||
void setPlopTest(int action){m_plop_test = action;}
|
||||
void setClearConsoleAction(int action){m_clear_console_action = action;}
|
||||
|
||||
void moveCursorLeft(){m_input_cursor_pos--;}
|
||||
void moveCursorRight(){m_input_cursor_pos++;}
|
||||
|
||||
bool isEnabled(){return m_shellEnabled;}
|
||||
bool isBufferResized(){return m_resizeBuffer;}
|
||||
bool indexMoved(){return m_indexMoved;}
|
||||
|
@ -1,28 +0,0 @@
|
||||
#include "system.h"
|
||||
|
||||
#include "messagebus.h"
|
||||
#include "message.h"
|
||||
#include "input.h"
|
||||
#include <iostream>
|
||||
|
||||
System::System()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InputSystem::InputSystem(){
|
||||
|
||||
}
|
||||
|
||||
void InputSystem::initInput(sf::Window *window){
|
||||
m_input = new Input(window);
|
||||
}
|
||||
|
||||
void InputSystem::update(){
|
||||
// int action;
|
||||
// Message* message;
|
||||
// while ((action = m_input->getAction()) != NO_ACTION){
|
||||
// message = new Message(std::to_string(action),SystemType::INPUT_SYSTEM);
|
||||
// m_msgBus->postMessage(message);
|
||||
// }
|
||||
}
|
36
src/system.h
36
src/system.h
@ -1,36 +0,0 @@
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
class MessageBus;
|
||||
class Message;
|
||||
class Input;
|
||||
|
||||
namespace sf{
|
||||
class Window;
|
||||
}
|
||||
|
||||
//TODO:complete this part with other existing system,
|
||||
enum SystemType {INPUT_SYSTEM, RENDERER_SYSTEM, IA_SYSTEM,GAME_SYSTEM,LENGTH};
|
||||
|
||||
class System
|
||||
{
|
||||
SystemType m_type;
|
||||
protected:
|
||||
MessageBus* m_msgBus;
|
||||
|
||||
public:
|
||||
System();
|
||||
virtual void handleMessage(Message* message) = 0;
|
||||
};
|
||||
|
||||
class InputSystem : public System{
|
||||
private:
|
||||
Input* m_input;
|
||||
public:
|
||||
InputSystem();
|
||||
~InputSystem();
|
||||
void initInput(sf::Window* window);
|
||||
void update();
|
||||
};
|
||||
|
||||
#endif // SYSTEM_H
|
@ -8,6 +8,7 @@
|
||||
#include <sparrowrenderer.h>
|
||||
#include <texture.h>
|
||||
#include <chunk.h>
|
||||
#include "defaultkeysmap.h"
|
||||
|
||||
#include <scene/scenetree.h>
|
||||
#include <scene/textnode.h>
|
||||
@ -29,29 +30,6 @@
|
||||
|
||||
#include "potator.h"
|
||||
|
||||
class myKeysMap : public IKeysMap{
|
||||
public:
|
||||
enum{MAIN_ACTION, SECONDARY_ACTION, MOVE_FORWARD, MOVE_BACKWARD, STRAFE_LEFT, STRAFE_RIGHT, TOGGLE_NOCLIP, TOGGLE_PHYSICS_DEBUG, TOGGLE_CONSOLE, EXIT_GAME};
|
||||
|
||||
myKeysMap(){
|
||||
keys.push_back( {MAIN_ACTION, sf::Keyboard::KeyCount + sf::Mouse::Left, IKeysMap::PRESSED} );
|
||||
keys.push_back( {SECONDARY_ACTION, sf::Keyboard::KeyCount + sf::Mouse::Right, IKeysMap::PRESSED} );
|
||||
keys.push_back( {MOVE_FORWARD, sf::Keyboard::Z, IKeysMap::HOLD} );
|
||||
keys.push_back( {MOVE_BACKWARD, sf::Keyboard::S, IKeysMap::HOLD} );
|
||||
keys.push_back( {STRAFE_LEFT, sf::Keyboard::Q, IKeysMap::HOLD} );
|
||||
keys.push_back( {STRAFE_RIGHT, sf::Keyboard::D, IKeysMap::HOLD} );
|
||||
keys.push_back( {TOGGLE_NOCLIP, sf::Keyboard::G, IKeysMap::PRESSED} );
|
||||
keys.push_back( {TOGGLE_PHYSICS_DEBUG, sf::Keyboard::P, IKeysMap::PRESSED} );
|
||||
keys.push_back( {TOGGLE_CONSOLE, sf::Keyboard::F3, IKeysMap::PRESSED} );
|
||||
keys.push_back( {EXIT_GAME, sf::Keyboard::Escape, IKeysMap::PRESSED} );
|
||||
}
|
||||
|
||||
static std::vector<int> getMap()
|
||||
{
|
||||
return {MAIN_ACTION, SECONDARY_ACTION, MOVE_FORWARD, MOVE_BACKWARD, STRAFE_LEFT, STRAFE_RIGHT, TOGGLE_NOCLIP, TOGGLE_PHYSICS_DEBUG, TOGGLE_CONSOLE, EXIT_GAME};
|
||||
}
|
||||
};
|
||||
|
||||
class TestGen : public TerrainGenerator
|
||||
{
|
||||
float map[64*64];
|
||||
@ -138,15 +116,24 @@ int main(){
|
||||
|
||||
// settin gup SparrowInput
|
||||
Input* input = engine.getInput();
|
||||
input->setKeysMap(myKeysMap());
|
||||
input->addContext(Context("default", myKeysMap::getMap()));
|
||||
input->setKeysMap(DefaultKeysMap());
|
||||
input->addContext(Context("default", DefaultKeysMap::getDefaultContext()));
|
||||
input->setCurrentContext("default");
|
||||
input->updateKeyBindings();
|
||||
engine.setTogglePhysicsDebugAction(myKeysMap::TOGGLE_PHYSICS_DEBUG);
|
||||
engine.setToggleShellAction(myKeysMap::TOGGLE_CONSOLE);
|
||||
engine.setExitGameAction(myKeysMap::EXIT_GAME);
|
||||
engine.setTogglePhysicsDebugAction(DefaultKeysMap::TOGGLE_PHYSICS_DEBUG);
|
||||
engine.setToggleShellAction(DefaultKeysMap::TOGGLE_CONSOLE);
|
||||
engine.setExitGameAction(DefaultKeysMap::EXIT_GAME);
|
||||
|
||||
/*
|
||||
//c'est un goup SparrowShell
|
||||
SparrowShell* shell = engine.getShell();
|
||||
shell->setMoveCursorLeftAction(DefaultKeysMap::MOVE_CURSOR_LEFT);
|
||||
shell->setMoveCursorRightAction(DefaultKeysMap::MOVE_CURSOR_RIGHT);
|
||||
shell->setPlopTest(DefaultKeysMap::PLOP_TEST);
|
||||
shell->setClearConsoleAction(DefaultKeysMap::CLEAR_CONSOLE);
|
||||
input->addContext(Context("shell",DefaultKeysMap::getShellContext()));
|
||||
input->updateKeyBindings();
|
||||
|
||||
/*
|
||||
// trackball camera
|
||||
TrackBallCameraNode *trackBallCam = new TrackBallCameraNode(engine.getInput());
|
||||
trackBallCam->setInputs(myKeysMap::SECONDARY_HOLD, myKeysMap::MAIN_HOLD);
|
||||
@ -155,14 +142,14 @@ int main(){
|
||||
*/
|
||||
// first person player controller
|
||||
PlayerCharacterNode *player = new PlayerCharacterNode(false);
|
||||
player->setInputs(myKeysMap::MOVE_FORWARD, myKeysMap::MOVE_BACKWARD, myKeysMap::STRAFE_LEFT, myKeysMap::STRAFE_RIGHT, myKeysMap::TOGGLE_NOCLIP);
|
||||
player->setInputs(DefaultKeysMap::MOVE_FORWARD, DefaultKeysMap::MOVE_BACKWARD, DefaultKeysMap::STRAFE_LEFT, DefaultKeysMap::STRAFE_RIGHT, DefaultKeysMap::TOGGLE_NOCLIP);
|
||||
scene->getRootObject()->addChild(player);
|
||||
scene->setMainCamera(player);
|
||||
player->setPosition(0.f, 15.f, 0.f);
|
||||
engine.getPhysics()->addRigidBody(player->getRigidbody());
|
||||
|
||||
// throw cubes and spheres with mouse clicks
|
||||
Potator *potator = new Potator(player, myKeysMap::MAIN_ACTION, myKeysMap::SECONDARY_ACTION);
|
||||
Potator *potator = new Potator(player, DefaultKeysMap::MAIN_ACTION, DefaultKeysMap::SECONDARY_ACTION);
|
||||
scene->getRootObject()->addChild(potator);
|
||||
|
||||
// lighting
|
||||
@ -178,10 +165,6 @@ int main(){
|
||||
engine.outputShell("Hello World!");
|
||||
engine.outputShell("Starting test :");
|
||||
|
||||
// for(int i = 0; i < 17; i++){
|
||||
// engine.outputShell(std::to_string(i));
|
||||
// }
|
||||
|
||||
// preparing shaders and launching the engine
|
||||
scene->updateShaders();
|
||||
engine.start();
|
||||
|
Loading…
x
Reference in New Issue
Block a user