summaryrefslogtreecommitdiffstats
path: root/kspaceduel/mainview.h
blob: d7ed1bdc854315e761c6e442cbed66bcb68e5aca (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef __MY_MAIN_VIEW_H
#define __MY_MAIN_VIEW_H

#include <tqwidget.h>
#include <tqimage.h>

class KToggleAction;
class KActionCollection;
#include <krandomsequence.h>

#include "sprites.h"
#include "dialogs.h"
class Ai;

#ifdef sun
#undef sun
#endif

class MyMainView:public TQWidget
{
   Q_OBJECT
  TQ_OBJECT
public:
   MyMainView(TQWidget *parent=0);
   ~MyMainView();

   static KToggleAction *pauseAction;
   void setActionCollection(KActionCollection *a);

public slots:
   void newRound();
   void newGame();
   void togglePause( );
   void pause();
   void resume();
   void start();
   void stop();
   void gameSetup();
   void closeSettings();
   void readConfig();
   void writeConfig();
signals:
   void hitPoints(int pn,int hp);
   void energy(int pn,int en);
   void wins(int pn,int w);
   void setStatusText(const TQString & str,int id);

protected:
   virtual void resizeEvent(TQResizeEvent *event);
   virtual void timerEvent(TQTimerEvent *event);
   virtual void keyPressEvent(TQKeyEvent *event);
   virtual void keyReleaseEvent(TQKeyEvent *event);
   SConfig modifyConfig(SConfig conf);
   TQCanvasPixmapArray* loadOldPixmapSequence(const TQString& datapattern,
                           const TQString& maskpattern, int framecount=1);
   void moveShips();
   void moveBullets();
   void moveMines();
   void moveExplosions();
   void calculatePowerups();
   void collisions();
private:
   KActionCollection *actionCollection;

   TQCanvas field;
   TQCanvasView view;

   SConfig customConfig,config;

   int timerID;
   bool playerKeyPressed[2][PlayerKeyNum];
   bool bulletShot[2];
   bool minePut[2];
   bool waitForStart;
   double gameEnd;
   double timeToNextPowerup;

// sprites
   TQPtrList<TQImage> shipImages;
   TQPtrList<TQPoint> points;
   TQImage bulletImage;
   TQCanvasPixmapArray *bulletsequence[2];
   TQCanvasPixmapArray *shipsequence[2];
   TQCanvasPixmapArray *explosionsequence;
   TQCanvasPixmapArray *minesequence[2];
   TQCanvasPixmapArray *mineexplosionsequence;
   TQCanvasPixmapArray *powerupsequence[PowerupSprite::PowerupNum];


   ShipSprite *ship[2];
   SunSprite *sun;
   TQCanvasText *textSprite;
   TQPtrList<BulletSprite> *bullets[2];
   TQPtrList<MineSprite> *mines[2];
   TQPtrList<ExplosionSprite> explosions;
   TQPtrList<PowerupSprite> powerups;

   KRandomSequence random;

//Ai
   Ai *ai[2];

};

#endif