-
Notifications
You must be signed in to change notification settings - Fork 2
HelloWorld Tutorial
Add GameObject* to class declaration of your scene ie.
uth::GameObject* helloGO;
After that simply create initialize GameObject in the Init function:
helloGO = new uth::GameObject();
Add text component for it is also very simple:
helloGO->AddComponent(new Text("kenpixel.ttf", 24.f));
helloGO->GetComponent<Text>("Text")->AddText("Hello World!");
If (and when) you want to see your gameobject on-screen you have to call objects Draw function in Scene's draw.
helloGO->Draw(uthEngine.GetWindow());
Adding animated sprite is just as easy:
Add gameobject to class declaration ->
create empty object ->
add AnimatedSprite component ->
animGO->AddComponent(new uth::AnimatedSprite(&uthRS.LoadTexture("planetsheet.tga"), 25, 5, 5, 10));
draw object ->
Update object every frame (add go's update to YourScene::Update(float dt))
animGO->Update(dT);
NOTE: Mouse origin is in the center of screen instead of upper-right corner. (This behavior might/should change during development.)
First we should correct origin with camera:
uthEngine.GetWindow().GetCamera().SetPosition(uthEngine.GetWindow().GetSize()/2);
Then we just replace object to new position every frame (YourScene::Update(float dt))
animGO->transform.SetPosition(uthInput.Mouse.Position());