SVN_SILENT made messages (.desktop file)
[kdegames.git] / kollision / mainarea.h
blob81c9433110c3cb3f3072379ad1900797fe1832ab
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 */
10 #ifndef MAINAREA_H
11 #define MAINAREA_H
13 #include <QTimer>
14 #include <QTime>
15 #include <QList>
16 #include <QGraphicsScene>
17 #include "audioplayer.h"
18 #include "animator.h"
19 #include "message.h"
21 class Renderer;
22 class Ball;
23 class Animation;
24 class QGraphicsSceneMouseEvent;
26 struct Collision;
28 class MainArea : public QGraphicsScene
30 Q_OBJECT
31 QTimer m_timer;
32 int m_last_time;
33 int m_last_game_time;
34 QTime m_time;
36 /// time interval between two balls being added
37 int m_ball_timeout;
39 int m_size;
40 Renderer* m_renderer;
41 QPixmap m_background;
42 Animator m_animator;
43 QFont m_msg_font;
45 QList<Ball*> m_balls;
46 QList<Ball*> m_fading;
47 Ball* m_man;
49 /// the blue ball is dead
50 bool m_death;
52 /// the falling animation is over, we're waiting for a new game to start
53 bool m_game_over;
55 bool m_paused;
56 int m_pause_time;
57 int m_penalty;
59 QList<MessagePtr> m_welcome_msg;
60 QList<MessagePtr> m_pause_msg;
62 AudioPlayer m_player;
64 double radius() const;
65 QPointF randomPoint() const;
66 QPointF randomDirection(double val) const;
68 Ball* addBall(const QString& id);
69 bool collide(const QPointF& a, const QPointF& b,
70 double diam, Collision& collision);
72 Animation* writeMessage(const QString& text);
73 Animation* writeText(const QString& lines, bool fade = true);
74 void displayMessages(const QList<KSharedPtr<Message> >& msgs);
75 void playSound(int sound);
76 void onDeath();
77 void setManPosition(const QPointF& p);
78 void drawBackground(QPainter*, const QRectF&);
79 void updateSounds();
80 protected:
81 virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
82 virtual void focusOutEvent(QFocusEvent*);
83 public:
84 MainArea();
85 ~MainArea();
86 void start();
87 public slots:
88 void tick();
89 void enableSounds(bool enable);
90 void abort();
91 void togglePause();
92 signals:
93 void starting();
94 void gameOver(int);
95 void changeBallNumber(int);
96 void changeGameTime(int);
97 void changeState(bool);
98 void pause(bool);
101 #endif // MAINAREA_H