• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

kapman

  • sources
  • kde-4.12
  • kdegames
  • kapman
gameview.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "gameview.h"
19 #include "gamescene.h"
20 
21 GameView::GameView(Game * p_game) : QGraphicsView(new GameScene(p_game)) {
22  setFrameStyle(QFrame::NoFrame);
23  setFocusPolicy(Qt::StrongFocus);
24  // Forward the key press events to the Game instance
25  connect(this, SIGNAL(keyPressed(QKeyEvent*)), p_game, SLOT(keyPressEvent(QKeyEvent*)));
26 }
27 
28 GameView::~GameView() {
29 
30 }
31 
32 void GameView::resizeEvent(QResizeEvent*) {
33  fitInView(sceneRect(), Qt::KeepAspectRatio);
34 }
35 
36 void GameView::focusOutEvent(QFocusEvent*) {
37  // Pause the game if it is not already paused
38  if (((GameScene*)scene())->getGame()->getTimer()->isActive()) {
39  ((GameScene*)scene())->getGame()->switchPause();
40  }
41 }
42 
43 void GameView::keyPressEvent(QKeyEvent* p_event) {
44  emit(keyPressed(p_event));
45 }
46 
Game
This class manages the game main loop : it regularly checks the key press events, computes the charac...
Definition: game.h:35
gamescene.h
GameScene
This class contains all the Game elements to be drawn on the screen by the GameView instance...
Definition: gamescene.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:44:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kapman

Skip menu "kapman"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal