/
template_game.h
88 lines (63 loc) · 1.61 KB
/
template_game.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// template_game.h
// ld48jovoc
//
// Created by Joel Davis on 8/22/12.
// Copyright (c) 2012 Joel Davis. All rights reserved.
//
#ifndef ld48jovoc_template_game_h
#define ld48jovoc_template_game_h
#include <SDL.h>
#include <SDL_endian.h>
// minibasecode
#include <font.h>
#include <png_loader.h>
#include <shapes.h>
// Simple 'controller'-like presses (multiple can be pressed)
// for movement
enum
{
BTN_LEFT = ( 1 << 0 ),
BTN_RIGHT = ( 1 << 1 ),
BTN_UP = ( 1 << 2 ),
BTN_DOWN = ( 1 << 3 ),
BTN_A = ( 1 << 4 ),
BTN_B = ( 1 << 5 ),
};
class TemplateGame
{
public:
TemplateGame();
void init();
void updateSim( float dtFixed );
void updateFree( float dtRaw );
void redraw();
void shutdown();
void mouseMotion( float x, float y );
void mouseButton( SDL_MouseButtonEvent &btnEvent );
void updateButtons( unsigned int btnMask );
void keypress( SDLKey &key );
protected:
void _draw3d();
void _draw2d();
// Helper to draw a DrawVert based mesh
void _drawMesh( QuadBuff<DrawVert> *mesh );
private:
// The font
PNGImage m_fontImg;
Font *m_nesFont;
// A shape to draw
QuadBuff<DrawVert> *m_cube;
GLint m_basicShader;
PNGImage m_simpleTex;
// camera stuff
matrix4x4f m_proj;
matrix4x4f m_modelview;
matrix4x4f m_modelviewProj;
float m_rotate;
};
// The generated font data
// This is the NES font I used for LD20, within the rules to reuse this
// if necessary but should probably replace it ASAP
Font *makeFont_nesfont_8( GLuint fontTex );
#endif