source: abuse/trunk/src/imlib/event.cpp @ 652

Last change on this file since 652 was 652, checked in by Sam Hocevar, 11 years ago

imlib: merge JCMouse into EventHandler?.

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 2001 Anthony Kruize <trandor@labyrinth.net.au>
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This program is free software; you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation; either version 2 of the License, or
9 *  (at your option) any later version.
10 *
11 *  This program is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with this program; if not, write to the Free Software Foundation,
18 *  Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 */
20
21#if defined HAVE_CONFIG_H
22#   include "config.h"
23#endif
24
25#include "common.h"
26
27#include "event.h"
28#include "video.h"
29#include "filter.h"
30
31//
32// Constructor
33//
34EventHandler::EventHandler(image *screen, palette *pal)
35{
36    CHECK(screen && pal);
37    last_keystat = get_key_flags();
38    m_pending = 0;
39
40    m_screen = screen;
41
42    // Mouse stuff
43    uint8_t mouse_sprite[]=
44    {
45        0, 2, 0, 0, 0, 0, 0, 0,
46        2, 1, 2, 0, 0, 0, 0, 0,
47        2, 1, 1, 2, 0, 0, 0, 0,
48        2, 1, 1, 1, 2, 0, 0, 0,
49        2, 1, 1, 1, 1, 2, 0, 0,
50        2, 1, 1, 1, 1, 1, 2, 0,
51        0, 2, 1, 1, 2, 2, 0, 0,
52        0, 0, 2, 1, 1, 2, 0, 0,
53        0, 0, 2, 1, 1, 2, 0, 0,
54        0, 0, 0, 2, 2, 0, 0, 0
55    };
56
57    Filter f;
58    f.Set(1, pal->brightest(1));
59    f.Set(2, pal->darkest(1));
60    image *im = new image(vec2i(8, 10), mouse_sprite);
61    f.Apply(im);
62
63    m_sprite = new sprite(screen, im, 100, 100);
64    m_pos = m_lastpos = screen->Size() / 2;
65    m_button = m_lastbutton = 0;
66    m_center = vec2i(0, 0);
67
68    // Platform-specific stuff
69    SysInit();
70}
71
72//
73// Destructor
74//
75EventHandler::~EventHandler()
76{
77    ;
78}
79
80//
81// flush_screen()
82// Redraw the screen
83//
84void EventHandler::flush_screen()
85{
86    update_dirty(main_screen);
87}
88
89//
90// add_redraw()
91// Add a redraw rectangle.
92//
93void EventHandler::add_redraw(int X1, int Y1, int X2, int Y2, void *start)
94{
95    Event *ev;
96    ev = new Event;
97    ev->type = EV_REDRAW;
98    ev->redraw.x1 = X1;
99    ev->redraw.x2 = X2;
100    ev->redraw.y1 = Y1;
101    ev->redraw.y2 = Y2;
102    ev->redraw.start = start;
103    Push(ev);
104}
105
Note: See TracBrowser for help on using the repository browser.