Skip to content

Commit

Permalink
feat: lots of basic code
Browse files Browse the repository at this point in the history
  • Loading branch information
tolstenko committed Nov 22, 2022
1 parent f411699 commit b58395b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SET(ENGINE_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "ENGINE INCLUDE SOURCE

add_library (engine STATIC ${ENGINE_SRC} ${ENGINE_SRC_COMPONENTS} ${ENGINE_INC} ${ENGINE_INC_COMPONENTS})

#target_link_libraries(engine libglew_static)
target_link_libraries(engine glm)

IF(EMSCRIPTEN)
target_compile_options(engine PUBLIC "-O0")
Expand Down
1 change: 1 addition & 0 deletions engine/Component.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "Component.h"
18 changes: 18 additions & 0 deletions engine/Component.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef MOBAGEN_ENGINE_COMPONENT_H_
#define MOBAGEN_ENGINE_COMPONENT_H_

#include "Object.h"
class Component: public Object {
private:
// todo: add active and enabled logic
// todo: access the reference of the game object and the transform
public:
Component()= default;
virtual void Start(){};
virtual void OnGui(){};
virtual void OnDraw(){};
virtual void Update(){};
// todo: get the transform and game object associated
};

#endif //MOBAGEN_ENGINE_COMPONENT_H_
25 changes: 24 additions & 1 deletion engine/GameObject.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
#ifndef MOBAGEN_ENGINE_GAMEOBJECT_H_
#define MOBAGEN_ENGINE_GAMEOBJECT_H_

class GameObject {
#include "Object.h"
#include "Transform.h"
// a game object attaches components/behaviors
class GameObject: public Object {
private:
Transform _transform;
public:
const Transform& transform() const { return _transform; }

public:
template<class T>
std::vector<T> GetComponents();

template<class T>
std::vector<T> GetComponentsInChildren();

template<class T>
std::vector<T> GetComponentsInParent();

template<class T>
T* AddComponent();

static GameObject* Find(std::string name);

// todo: tag, layer, sendmessage
};

#endif //MOBAGEN_ENGINE_GAMEOBJECT_H_
5 changes: 5 additions & 0 deletions engine/Transform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by atolstenko on 11/22/2022.
//

#include "Transform.h"
8 changes: 8 additions & 0 deletions engine/Transform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef MOBAGEN_ENGINE_TRANSFORM_H_
#define MOBAGEN_ENGINE_TRANSFORM_H_

class Transform {

};

#endif //MOBAGEN_ENGINE_TRANSFORM_H_

0 comments on commit b58395b

Please sign in to comment.