Skip to content

Game Development

What can we say - we like games. And you can use Qt to write some. Questions? Ask here.
862 Topics 4.0k Posts
  • Translation of a scene node

    1
    0 Votes
    1 Posts
    592 Views
    No one has replied
  • QSDDynamicTexture Creation

    1
    0 Votes
    1 Posts
    683 Views
    No one has replied
  • Adding color to QGLBuilder object

    2
    0 Votes
    2 Posts
    788 Views
    S

    Hey, i figured it out. You just need to change the painter properties and set it to the new node. @painter->setStandardEffect(QGL::LitMaterial);
    painter->setFaceColor(QGL::AllFaces, QColor(170, 202, 0));
    cube->draw(painter);
    painter->setFaceColor(QGL::AllFaces, QColor(200, 202, 0));
    trident->draw(painter);@

  • Create 2d mobile game with QML

    6
    0 Votes
    6 Posts
    7k Views
    F

    Hi,
    I just saw this thread now so I'm a bit late in the discussion, but anyways, here my thoughts about it:

    Short answer to your question: YES, Qt Quick (QML & JavaScript) is sufficient for high performance games. For examples, you can have a look at some V-Play showcase games that run with 60fps across devices & platforms:

    "Chicken Outbreak":http://v-play.net/showcases/#chicken_outbreak2 - a physics based falldown game similar to Doodle Jump "Squaby Tower Defense":http://v-play.net/showcases/#squaby - a TD strategy game with user-generated content "Flappy Bird":http://v-play.net/doc/howto-flappybird-game/ - a Flappy Bird game fully made with QML 10 more games available "here":http://v-play.net/doc/vplay-examples/

    These games are published in the app stores (see the download links "here":http://v-play.net/showcases ), and also available open-source, so you can have a look at how they are made with QML.

    The only thing where you need to be careful about, is to do the right things with Qt Quick.

    These tasks are better suited for C++ for example:

    entity movement, either with animations or physics-based any computational complex algorithms like AI in general, things that are happening per-entity per frame

    That's why we did implement most of our "core game engine components":http://v-play.net/doc/vplay-group/ in C++. What is then left for QML, is the UI and the whole game logic. Most game logic is event-driven anyway (e.g. do something when 2 objects collide, or do something every x ms), so this is fast enough to be done with JavaScript.

    In general, I'd recommend starting development with as much in QML as possible - the time & code you save during is well worth it! As JKSH wrote, you get a very good rendering performance thanks to the Qt Scene Graph.. If you then realize performance issues (e.g. with the Qt Quick profiler of Qt Creator), you can move the parts where you have problems to C++ later.

    Cheers,
    Chris

  • New QT/QML trading card wargame!

    15
    0 Votes
    15 Posts
    5k Views
    M

    Thanks - the Tutorial issue is a bit of a thorny one - it IS a bit long (20-30 mins), but it's pretty well all needed. I will think about ways to break it up though, it's a good idea (though maybe hard to do in practice).

    UI- hopefully the in-game UI is OK (if in need of a bit of art to reduce reliance on boxes). The out-of-game bits are very rough and ready I know, I'm working on those at the moment.

    Getting alpha testers is a big issue here - posting on various forums didn't get that far, but I've now got a facebooking game blogger type person involved who'll be taking on this side.

    And am also, as I type, working on an in-game feedback mechanism for testers...

    Thanks again for the input - appreciated!

    M.

  • Getting Started Designing Game

    5
    0 Votes
    5 Posts
    3k Views
    F

    Hi,
    welcome to the game development world with Qt. :)

    Don't give up on learning - the "wow I've made that!?" moments are getting more over time. ;)

    You can choose C++ or QML/Qt Quick for developing your games, although I'd recommend QML for getting started and for the game logic as you need less lines of codes and are a lot faster in development.
    The performance-sensitive parts are still best with C++ and integration with QML & C++ is quite straightforward with Qt, so learning C++ is never a bad thing!

    To help you get started, you can have a look at some of our Qt Quick tutorials to learn game development:

    "How to make a simple BalloonPop game with V-Play":http://v-play.net/doc/howto-balloon-game/ "How to make a physics-based game step by step":http://v-play.net/doc/vplay-entity-concept/ "How to make a Flappy Bird Game":http://v-play.net/doc/howto-flappybird-game/ "How to create mobile games for different screen sizes and resolutions":http://v-play.net/doc/vplay-different-screen-sizes/ "How to create mobile games with multiple scenes and multiple levels":http://v-play.net/doc/howto-multi-scene-multi-level/

    You can also have a look at our open-source games for puzzle games, arcade, action, etc.:
    http://v-play.net/doc/vplay-examples/

    Cheers,
    Chris

  • Qt-Game for mobile devices

    3
    0 Votes
    3 Posts
    1k Views
    F

    Hi,
    I've just posted some help how to support multiple screens in another support thread, maybe that's also helpful in your case:
    http://qt-project.org/forums/viewthread/47833/

    For the multiplayer topic, it depends how complex you want to go..
    You need to decide what is calculated by the server (the player who hosts the game) and what by the client. For example you can do the calculation of the ball + server & client player movement on the server, and send the ball coordinates & server player position to the client. To make it smooth, you will probably need to interpolate these positions on the client.

    Anyways, local multiplayer on 1 device would be much easier... ;)
    We did that in a Pong game and open-sourced it - you can see the sources here: http://v-play.net/doc/v1/demos-vpong/

    And a tutorial how to make a Pong game here: http://v-play.net/doc/v1/howto-pong-game/

    Cheers,
    Chris

  • How to support multi-screen in a game?

    2
    0 Votes
    2 Posts
    1k Views
    F

    Hi Mike,
    Qt does not support that by default, that's why we added it on top of it as part of "V-Play Game Engine":http://v-play.net, which is based on Qt 5.

    With our additions you can do this:

    1.) Dynamic Image Switching
    You can put your images of different quality into separate folders (similar to cocos2d-x version 2). For example your "single definition" or "sd" image has 100x100px, then you can provide a high definition (retina) image with 200x200px and put it into the +hd subfolder. If you also want to target high-density screens like the iPad 3, you can provide an image with 400x400px in the +hd2 subfolder. The images of these subfolders are then used & selected automatically by V-Play. So provide your imgages in this folder structure:

    image.png
    +hd/image.png
    +hd2/image.png

    2.) Content Scaling
    To be able to make your game work across multiple resolutions and aspect ratios, we added content scaling to the engine. That way, you have a single logical resolution to work with, and then it gets scaled up by your chosen "scaleMode":http://v-play.net/doc/vplay-scene/#scaleMode-prop. This "single logical or virtual resolution" (which is 480x320 or 320x480 in portrait games by default) has the advantage that it makes your game fair & comparable across devices, and you don't have to worry about different aspect ratios & resolutions.

    You can still use the whole screen, by using "gameWindowAnchorItem":http://v-play.net/doc/vplay-scene/#gameWindowAnchorItem-prop or setting the scaleMode or "sceneAlignment":http://v-play.net/doc/vplay-scene/#sceneAlignmentX-prop to what works best for your game.

    Also, I'd recommend making your background a bit bigger (See "here":http://v-play.net/doc/vplay-different-screen-sizes/#letterbox for exact sizes and a Photoshop template), to fill the whole screen no matter what aspect ratio your game is running on.

    Here is some additional information on these topics, taken from the V-Play documentation:

    Dynamic Image Switching Support

    V-Play adds support for dynamic image switching based on the screen size, on top of Qt 5. This allows you to:

    Save graphics memory: based on the screen size, the best matching image is selected to avoid upscaled and blurry images, and to save memory compared to an approach where always the highest resolution images are used. Improve loading times: as the best-sized image is selected, you get an ideal loading time of the used image. Work with the logical size of the image in your GameWindow and Scene to simplify multi-resolution positioning and to use Content Scaling.

    You can check out the "V-Play File Selectors documentation":http://v-play.net/doc/vplay-multiresolutionimage/#v-play-file-selectors for more details about dynamic image switching.

    Content Scaling

    Content Scaling allows you to create a game once for all screen sizes and resolutions. V-Play simplifies working with a single logical size with these use-cases:

    Position your game entities on a logical scene for equal and fair game experience across all platforms. Easy positioning of UI elements based on the screen and not based on the logical scene. See here for a tutorial. Easily define physics objects across devices. Without this addition, each physics object would behave differently because its dimensions would depend on the physical screen size. V-Play solves this issue. Keep entity positions in levels consistent across screen resolutions: If one level is saved on one resolution and then played on another device with a different resolution, the level would look different. V-Play solves this issue.

    Content scaling can be used with the "MultiResolutionImage":http://v-play.net/doc/vplay-multiresolutionimage/, "AnimatedSpriteVPlay":http://v-play.net/doc/vplay-animatedspritevplay/ and "SpriteSequenceVPlay":http://v-play.net/doc/vplay-spritesequencevplay/ components.

    You can also have a look at our tutorial:
    "How to create mobile games for different screen sizes and resolutions":http://v-play.net/doc/vplay-different-screen-sizes/

    Additionally, we'll release a blog post next week how to write density-independent and resolution-independent games next week. I'll post the link here then.

    Best,
    Chris

  • Unity 3d and QT 5.3, is possible ?

    4
    0 Votes
    4 Posts
    9k Views
    F

    You can also use Qt3D for animating the character. it depends on your project and also your experience what is better - if you have a lot of UI, or are experienced with Qt and/or Qt Quick Qt might be the better option.

  • Import a tile map in Qt app

    1
    0 Votes
    1 Posts
    964 Views
    No one has replied
  • How to build Bacon2D for android?

    2
    0 Votes
    2 Posts
    1k Views
    SGaistS

    Hi,

    AFAICS, you built Bacon2D with your Desktop Qt. You should call the qmake from your android Qt build.

    Hope it helps

  • 0 Votes
    2 Posts
    2k Views
    T

    Hi,

    Events are a mechanism of QObject: your OpenGL context can't detect you're hovering a drawn primitive. Nevertheless you can track your cursor inside your widget -- just activate "mouse tracking":http://qt-project.org/doc/qt-5/qwidget.html#mouseTracking-prop on it and handle events by reimplementing QGLWidget::mouseMoveEvent() -- an then detect the primitive hovered with OpenGL picking. Show the coordinates on the screen using "QGLWidget::renderText()":http://qt-project.org/doc/qt-5/qglwidget.html#renderText.

  • Do I need a texture atlas

    5
    0 Votes
    5 Posts
    3k Views
    A

    Great, thanks for the info sletta.

    Qt really does make simple games easy to develop.

  • Joystick with force feedback in Qt

    3
    0 Votes
    3 Posts
    2k Views
    H

    Ok, thank you for response.

  • 0 Votes
    6 Posts
    6k Views
    JKSHJ

    You're welcome! :) If your problem is solved, please edit your original post and add "[SOLVED]" to the title.

    [quote author="mr_jaro" date="1410057174"]I passed pixmap through constructor and in painting I used "pixmap()".

    ...

    In Scene I made it like this:
    @
    painter.drawPixmap(0, 0, pixmap());
    @
    [/quote]You don't need QPainter, and you don't need to override paint() or paintEvent().

    Just add your PNG file to the scene like this:
    @
    QGraphicsPixmapItem pic = new QGraphicsPixmapItem();
    pic.setPixmap(new QPixmap("ttt.png"));

    QGraphicsScene scene = new QGraphicsScene();
    scene.addItem(pic);

    QGraphicsView view = new QGraphicsView(scene);
    view.show();

    // (My Java is rusty, so my code might be slightly wrong)
    @

    That's it. Your PNG image will now be displayed.

    Then, move it around like this:
    @
    pic.setPos(100, 100);
    @

    If you want to show an image in a widget, just use a QLabel. (Again, you don't need to override paintEvent())

    [quote]Sorry for leaving comments but want’ed to keep it so you could see the ways I was trying to resolve it.[/quote]That's fair enough :)

  • 0 Votes
    2 Posts
    4k Views
    slettaS

    Be aware of that QOpenGLShader will insert

    @#define highp
    #define mediump
    #define lowp@

    at the top of your glsl code when you are compiling for desktop. And on desktop, 'precision' is not a valid token until one of the later versions (exactly which one I can't remember right now).

    So based on that, I'd say that you are compiling for desktop and it fails on line 4 (7 - 3 inserted lines) of your code because 'precision' is not a valid keyword.

    QOpenGLShaderProgram tries to help in this regard by defining the precision specifiers to empty on desktop, so if you change your code to:

    @lowp varying vec4 color;
    void main() {
    gl_FragColor = color;
    }@

    it will compile for both desktop and es.

  • GUI game help needed

    2
    0 Votes
    2 Posts
    1k Views
    T

    I have written a simple 2D game with Qt + PyQt and found that Python and Qt works together really well. PySide in another option for Python bindings, you may want to do some research and choose the one that suits for your needs.

    Basic gist is to start QApplication, show a window (QMainWindow in my case) and start the event loop that will start responding to user event (mouse, keyboard and such). It's been a while, since I worked on that part, but if you want to have a look, it's here: https://github.com/tuturto/pyherc/blob/master/src/herculeum/ui/gui/mainwindow.py

  • Can't Use OpenGL ES 2.0 identifiers

    1
    0 Votes
    1 Posts
    694 Views
    No one has replied
  • 0 Votes
    8 Posts
    4k Views
    G

    yes, I take code from this example, thank you

  • Cute3D Game Engine

    16
    0 Votes
    16 Posts
    7k Views
    R

    People,

    We release the Cute3D official logo on our facebook page. Follow us, soon more informations!!!

    https://www.facebook.com/sunlandstudios

    Best regards,
    Renato Dias Viana
    CTO, Sunland Studios