Commits

ascetic85 committed 111e31f

[new] separate GameEngine with libGE and GETest project

  • Participants
  • Parent commits 0630c0b

Comments (0)

Files changed (61)

GETest/GETest.pro

+#-------------------------------------------------
+#
+# Project created by QtCreator 2012-12-18T15:48:41
+#
+#-------------------------------------------------
+
+QT          +=  multimedia core gui opengl
+CONFIG      +=  mobility
+MOBILITY    += systeminfo \
+                multimedia
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = GETest
+TEMPLATE = app
+
+INCLUDEPATH += ../Srcs
+
+CONFIG(debug,debug|release): LIBS += -L../debug -llibGE
+CONFIG(release,debug|release): LIBS += -L../release -llibGE
+
+SOURCES += main.cpp \
+    main_menu.cpp
+
+HEADERS += \
+    main_menu.h
+#include <QtGui/QApplication>
+#include <QDir>
+//here's the first one to change
+#include <game_engine.h>
+#include "main_menu.h"
+
+
+int main(int argc, char *argv[])
+{
+#ifdef useOpenGL
+//    QApplication::setGraphicsSystem("opengl");
+#else
+    QApplication::setGraphicsSystem("raster");
+#endif
+    QApplication app(argc, argv);
+
+    FileUtils::shareFileUtils()->setResourceDirectory("resource");
+
+    //set up audio playback
+    AudioManager::setUpAudioManager();
+
+    //here is the second main_menu to change
+    Director::sharedDirector()->startWithScene(MainMenu::scene());
+
+    return app.exec();
+}

GETest/main_menu.cpp

+#include "main_menu.h"
+
+Scene* MainMenu::scene() {
+    Scene *scene = Scene::node();
+    MainMenu* layer = new MainMenu;
+    scene->addChild(layer);
+    return scene;
+}
+
+
+MainMenu::MainMenu()
+{
+    qDebug() << Q_FUNC_INFO;
+    //taking screen size, saving it to variable called winSize
+    m_winSize = Director::sharedDirector()->winSizeInPixels();
+
+    //we'll start by adding a sprite that represents the background for the menu
+    m_background = Sprite::spriteWithImage("wallpaper.jpg");
+    m_background->setPos(m_winSize.width()/2,m_winSize.height()/2);
+    addChild(m_background);
+    QString fileName;
+    QString temp;
+    Sprite *newCard;
+    qreal offset = 100;
+    //we'll creat the 13 club cards
+    fileName = "c.png";
+    for (int i = 1; i <= 13; i++) {
+        temp = QString().setNum(i);
+        temp.append(fileName);
+        newCard = Sprite::spriteWithImage(temp.toAscii());
+        m_cards.append(newCard);
+        newCard->setPos(offset,offset);
+        addChild(newCard);
+    }
+    //we'll creat the 13 diamond cards
+    fileName = "d.png";
+    for (int i = 1; i <= 13; i++) {
+        temp = QString().setNum(i);
+        temp.append(fileName);
+        newCard = Sprite::spriteWithImage(temp.toAscii());
+        m_cards.append(newCard);
+        newCard->setPos(offset,offset);
+        addChild(newCard);
+    }
+    //we'll creat the 13 heart cards
+    fileName = "h.png";
+    for (int i = 1; i <= 13; i++) {
+        temp = QString().setNum(i);
+        temp.append(fileName);
+        newCard = Sprite::spriteWithImage(temp.toAscii());
+        m_cards.append(newCard);
+        newCard->setPos(offset,offset);
+        addChild(newCard);
+    }
+    //we'll creat the 13 Spade cards
+    fileName = "s.png";
+    for (int i = 1; i <= 13; i++) {
+        temp = QString().setNum(i);
+        temp.append(fileName);
+        newCard = Sprite::spriteWithImage(temp.toAscii());
+        m_cards.append(newCard);
+        newCard->setPos(offset,offset);
+        addChild(newCard);
+    }
+    m_counter = 0;
+    animation();
+}
+
+void MainMenu::animation() {
+    if (m_counter < m_cards.size()) {
+        m_cards.at(m_counter)->runSequence(Sequence::sequenceWithActions(Action::easeinout(Action::moveBy(0.5,300,200)),Action::FuncCall(this,SLOT(animation())),NULL));
+        m_cards.at(m_counter)->runAction(Action::easeinout(Action::rotateBy(0.5,360)));
+        AudioManager::playSound("alert.wav");
+        AudioManager::playSound("play_card.wav");
+        m_counter++;
+    }
+}
+
+void MainMenu::update(double delta) {
+//    runAction(action::rotateBy(4,360));
+    runAction(Action::easeinout(Action::scaleTo(1,1)));
+    runAction(Action::fadeTo(1,100));
+    unSchedualUpdate();
+}
+
+
+void MainMenu::onEnterTransitionDidStart() {
+    qDebug() << Q_FUNC_INFO;
+}
+
+void MainMenu::onEnterTransitionDidFinish() {
+    qDebug() << Q_FUNC_INFO;
+}
+
+void MainMenu::onExitTransitionDidStart() {
+    qDebug() << Q_FUNC_INFO;
+}
+
+void MainMenu::onExitTransitionDidFinish() {
+    qDebug() << Q_FUNC_INFO;
+}
+

GETest/main_menu.h

+#ifndef MAIN_MENU_H
+#define MAIN_MENU_H
+
+#include <game_engine.h>
+#include <QList>
+
+class MainMenu : public Layer
+{
+    Q_OBJECT
+
+public:
+    static Scene* scene();
+    explicit MainMenu();
+//    void onEnterTransitionDidFinish();
+//    void onExitTransitionDidFinish();
+    void onEnterTransitionDidStart();
+    void onEnterTransitionDidFinish();
+    void onExitTransitionDidStart();
+    void onExitTransitionDidFinish();
+
+public slots:
+    void update(double delta);
+    void animation();
+
+private:
+    QRect m_winSize;
+    qreal m_backGroundHeight;
+    Sprite *m_background;
+    QList<Sprite*> m_cards;
+    int m_counter;
+};
+
+#endif // MAIN_MENU_H

GETest/resource/10c.png

Added
New image

GETest/resource/10d.png

Added
New image

GETest/resource/10h.png

Added
New image

GETest/resource/10s.png

Added
New image

GETest/resource/11c.png

Added
New image

GETest/resource/11d.png

Added
New image

GETest/resource/11h.png

Added
New image

GETest/resource/11s.png

Added
New image

GETest/resource/12c.png

Added
New image

GETest/resource/12d.png

Added
New image

GETest/resource/12h.png

Added
New image

GETest/resource/12s.png

Added
New image

GETest/resource/13c.png

Added
New image

GETest/resource/13d.png

Added
New image

GETest/resource/13h.png

Added
New image

GETest/resource/13s.png

Added
New image

GETest/resource/1c.png

Added
New image

GETest/resource/1d.png

Added
New image

GETest/resource/1h.png

Added
New image

GETest/resource/1s.png

Added
New image

GETest/resource/2c.png

Added
New image

GETest/resource/2d.png

Added
New image

GETest/resource/2h.png

Added
New image

GETest/resource/2s.png

Added
New image

GETest/resource/3c.png

Added
New image

GETest/resource/3d.png

Added
New image

GETest/resource/3h.png

Added
New image

GETest/resource/3s.png

Added
New image

GETest/resource/4c.png

Added
New image

GETest/resource/4d.png

Added
New image

GETest/resource/4h.png

Added
New image

GETest/resource/4s.png

Added
New image

GETest/resource/5c.png

Added
New image

GETest/resource/5d.png

Added
New image

GETest/resource/5h.png

Added
New image

GETest/resource/5s.png

Added
New image

GETest/resource/6c.png

Added
New image

GETest/resource/6d.png

Added
New image

GETest/resource/6h.png

Added
New image

GETest/resource/6s.png

Added
New image

GETest/resource/7c.png

Added
New image

GETest/resource/7d.png

Added
New image

GETest/resource/7h.png

Added
New image

GETest/resource/7s.png

Added
New image

GETest/resource/8c.png

Added
New image

GETest/resource/8d.png

Added
New image

GETest/resource/8h.png

Added
New image

GETest/resource/8s.png

Added
New image

GETest/resource/9c.png

Added
New image

GETest/resource/9d.png

Added
New image

GETest/resource/9h.png

Added
New image

GETest/resource/9s.png

Added
New image

GETest/resource/alert.wav

Binary file added.

GETest/resource/config.ini

+width=480
+height=320

GETest/resource/play_card.wav

Binary file added.

GETest/resource/wallpaper.jpg

Added
New image
+TARGET = libGE
+TEMPLATE = lib
+#CONFIG += stdbinary
+CONFIG += staticlib
+
+# Add files and directories to ship with the application
+# by adapting the examples below.
+# file1.source = myfile
+# dir1.source = mydir
+DEPLOYMENTFOLDERS = # file1 dir1
+
+
+# Uncomment/comment the following line to enable/disable debug prints of
+# Qt GameEnabler audio framework.
+#DEFINES += GE_DEBUG
+
+# If your application uses the Qt Mobility libraries, uncomment
+# the following lines and add the respective components to the
+# MOBILITY variable.
+
+QT += multimedia core gui opengl
+CONFIG += mobility
+MOBILITY += systeminfo \
+            multimedia
+
+#after having these, create a folder resourc and add to it all the images, sounds that you want to use in your game
+
+MOC_DIR = moc
+OBJECTS_DIR = obj
+unix:!symbian:!maemo5:!win {
+    #Special case for N950 that works, all other devices will use the else case
+    dir1.files = resourc/*
+    dir1.path  = /opt/
+#$${TARGET}
+    INSTALLS += dir1
+}
+win32 {
+    CONFIG(debug,debug|release) {
+        DEFINES += GE_DEBUG
+#        DEFINES += useOpenGL # black screen
+    }
+}
+else {
+    dir1.source += resourc/*
+    DEPLOYMENTFOLDERS = dir1
+}
+
+unix {
+    mac {
+        CONFIG -= app_bundle
+    }
+}
+
+symbian:TARGET.UID3 = 0xE2886576
+
+# Smart Installer package's UID
+# This UID is from the protected range
+# and therefore the package will fail to install if self-signed
+# By default qmake uses the unprotected range value if unprotected UID is defined for the application
+# and 0x2002CCCF value if protected UID is given to the application
+#symbian:DEPLOYMENT.installer_header = 0x2002CCCF
+
+# Allow network access on Symbian
+symbian:TARGET.CAPABILITY += NetworkServices
+
+# If your application uses the Qt Mobility libraries, uncomment
+# the following lines and add the respective components to the
+# MOBILITY variable.
+# CONFIG += mobility
+# MOBILITY +=
+
+SOURCES +=  \
+    Srcs/transitionscene.cpp \
+    Srcs/textitem.cpp \
+    Srcs/spriteitem.cpp \
+    Srcs/sprite.cpp \
+    Srcs/sequence.cpp \
+    Srcs/scene.cpp \
+    Srcs/node.cpp \
+    Srcs/menuitemlabel.cpp \
+    Srcs/menuitemimage.cpp \
+    Srcs/menuitem.cpp \
+    Srcs/menu.cpp \
+    Srcs/layer.cpp \
+    Srcs/label.cpp \
+    Srcs/graphicsscene.cpp \
+    Srcs/director.cpp \
+    Srcs/audiomanager.cpp \
+    Srcs/action.cpp \
+    Srcs/GEInterfaces.cpp \
+    Srcs/GEAudioOut.cpp \
+    Srcs/GEAudioMixer.cpp \
+    Srcs/GEAudioBufferPlayInstance.cpp \
+    Srcs/GEAudioBuffer.cpp \
+    Srcs/fileutils.cpp \
+    Srcs/view.cpp
+HEADERS += \
+    Srcs/transitionscene.h \
+    Srcs/textitem.h \
+    Srcs/spriteitem.h \
+    Srcs/sprite.h \
+    Srcs/sequence.h \
+    Srcs/scene.h \
+    Srcs/node.h \
+    Srcs/menuitemlabel.h \
+    Srcs/menuitemimage.h \
+    Srcs/menuitem.h \
+    Srcs/menu.h \
+    Srcs/layer.h \
+    Srcs/label.h \
+    Srcs/graphicsscene.h \
+    Srcs/global_keys.h \
+    Srcs/game_engine.h \
+    Srcs/game_config.h \
+    Srcs/director.h \
+    Srcs/audiomanager.h \
+    Srcs/action.h \
+    Srcs/trace.h \
+    Srcs/GEInterfaces.h \
+    Srcs/GEAudioOut.h \
+    Srcs/GEAudioMixer.h \
+    Srcs/GEAudioBufferPlayInstance.h \
+    Srcs/GEAudioBuffer.h \
+    Srcs/fileutils.h \
+    Srcs/view.h
+FORMS +=
+
+# Please do not modify the following two lines. Required for deployment.
+include(deployment.pri)
+qtcAddDeployment()
+
+OTHER_FILES += \
+    qtc_packaging/debian_harmattan/rules \
+    qtc_packaging/debian_harmattan/README \
+    qtc_packaging/debian_harmattan/manifest.aegis \
+    qtc_packaging/debian_harmattan/copyright \
+    qtc_packaging/debian_harmattan/control \
+    qtc_packaging/debian_harmattan/compat \
+    qtc_packaging/debian_harmattan/changelog \
+    qtc_packaging/debian_fremantle/rules \
+    qtc_packaging/debian_fremantle/README \
+    qtc_packaging/debian_fremantle/copyright \
+    qtc_packaging/debian_fremantle/control \
+    qtc_packaging/debian_fremantle/compat \
+    qtc_packaging/debian_fremantle/changelog
+
+
+
+
+
+
+
+
+
+
+
+
+