O'Reilly logo

Irrlicht 1.7 Realtime 3D Engine by Aung Sithu Kyaw, Johannes Stein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - moving a ball

With the knowledge acquired in this chapter and drawing 2D examples from previous chapters, we'll try to write a simple program where we'll have a ball moving towards wherever you click on the screen.

  1. Let's define some global variables first:
    ITexture* image; vector2d<f32> position; vector2d<f32> target; vector2d<f32> direction; f32 speed = 0.2f; s32 screenWidth = 640; s32 screenHeight = 480; Next we need to implement event receiver for mouse events. class MyEventReceiver: public IEventReceiver { public: virtual bool OnEvent(const SEvent& event) { if (event.EventType == EET_MOUSE_INPUT_EVENT) { if (event.MouseInput.isLeftPressed()) { target.X = (f32)event.MouseInput.X; target.Y = (f32)event.MouseInput.Y; direction ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required