mirror of
https://bitbucket.org/King_DuckZ/jumping-in-d.git
synced 2024-10-30 02:49:01 +00:00
84 lines
1.9 KiB
D
84 lines
1.9 KiB
D
/* Copyright 2015, Michele Santullo
|
|
* This file is part of "Jumping in D".
|
|
*
|
|
* "Jumping in D" is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* "Jumping in D" is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with "Jumping in D". If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
module gameobjjumping;
|
|
public import gameobj;
|
|
import derelict.sdl2.sdl;
|
|
import texture;
|
|
import std.stdio;
|
|
|
|
class GameObjJumping : GameObj {
|
|
//Don't disable this(), it's disable automatically when you define a
|
|
//custorm constructor.
|
|
//@disable this();
|
|
|
|
//Take the pointer to the renderer and set initial values
|
|
this (SDL_Renderer* parRenderer) {
|
|
m_renderer = parRenderer;
|
|
m_wants_to_quit = false;
|
|
}
|
|
|
|
~this() {
|
|
writeln("Destroying GameObj");
|
|
}
|
|
|
|
void prepare() {
|
|
string texture_name = "bcruiser_normal.bpg";
|
|
writeln("Loading texture %s", texture_name);
|
|
m_texture = Texture(texture_name, m_renderer);
|
|
}
|
|
|
|
void destroy() {
|
|
}
|
|
|
|
//This is the function that is called at every frame
|
|
void exec() {
|
|
SDL_RenderClear(m_renderer);
|
|
m_texture.draw();
|
|
SDL_RenderPresent(m_renderer);
|
|
m_wants_to_quit = do_events();
|
|
}
|
|
|
|
bool wants_to_quit() const {
|
|
return m_wants_to_quit;
|
|
}
|
|
|
|
private:
|
|
Texture m_texture;
|
|
SDL_Renderer* m_renderer;
|
|
bool m_wants_to_quit;
|
|
}
|
|
|
|
private bool do_events() {
|
|
SDL_Event eve;
|
|
while (SDL_PollEvent(&eve)) {
|
|
switch (eve.type) {
|
|
case SDL_KEYDOWN:
|
|
break;
|
|
|
|
case SDL_KEYUP:
|
|
break;
|
|
|
|
case SDL_QUIT:
|
|
return true;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return false;
|
|
}
|