
C++ Qt Game Tutorial 1 – Drawing the Player (rectangle)
Abdullah
Views: 176605
Like: 1156
==================
Announcement: Hey guys, just a quick announcement. Since creating these videos, I’ve built my own game engine on top of the Qt frame work. The engine makes creating games using Qt much easier. I have tutorials on how to use the engine here:
Announcement: Hey guys, just a quick announcement. Since creating these videos, I’ve built my own game engine on top of the Qt frame work. The engine makes creating games using Qt much easier. I have tutorials on how to use the engine here:
End of announcement
==================
We begin our journey of making games with C++ and Qt by gently introducing 3 fundamental Qt classes that you will use in every single one of your games. Specifically, we introduce QGraphicsScene, QGraphicsItem (QGraphicsRectItem to be specific) and QGraphicsView.
Get the code for this tutorial at:
If you need to learn C++ first, I recommend LearningLad’s tutorial series:
If you need to learn the fundamentals of Qt first, I recommend VoidRealms’s tutorial series:
09.01.2022
2rood bar shoma, agha koja zendegi mikoni?
Great guide man. So basically if you know C++, learning Qt is pretty much just scouring the documentation for the libraries you need haha.
thanks a lot
Really good tutorial for start. Speech clear and undestandable. Thanks a lot)
Thank you, this is just what the doctor ordered!!!!!
Very good material. You could energize you transcription
Hi, I want to move an object with mouse in game. How I can do it?
Thanks.
thank you this tutorial is really good ! BTW im also abdullah but my name is muhammad :p
@muhammad najat No problem! Thank you for watching 🙂 Hahaha nice! Nice to meet you abdullah 2 hahaha 🙂
Thanks for great videos
Hi Abdullah,
When iam trying to run this code its working well but the only issue it is showing a warning as "Fault tolerant heap shim applied to current process". I believe this is from main.cpp. It would be great if you suggest how to rectify this warning.
Hi Abdullah,
I have a small question. I feel it would be amazing if we can put a background like a city top view image as a background of player and enemy which moves in downward direction in a loop which make our player and enemy's looks like moving in forward direction, visualizing as a real video game. I tried to do this but the issue is qgraphicspxelitem is not letting me to scale the image larger than qgraphicview. I hope you understood my issue. Please suggest if it is possible to do so or not. Is there any other way to do it.
Thank You.
ITs so annoying. I come from eclipse for Java and JavaFX. Things just work. When i try to compile here i have to "build"-> cleanAll, "build"->q make, when i press the green arrow it says QT creater needs a compiler set up to build. I press on that computer over the green error select debug, i select build i select release. Things just dont work.
I only want to learn qt, c++ and this shit won't let me. Its so incredible frustrating im really pissed off -.- Dont want to spend my time googlilng 2 hours and every solution is just shit.
I know you cannot help me i was just fucking frustrated as you can see in my langauge which usually is more friendly.
Thanks for your great tutorials anyway you are a perfect teacher if things would work i would already be able to have a simple game running. It would be so wonderful -.-
after selecting new project i am not getting any option to select the types of kit to be used…how to install sdk for qt.
Thank you ( عبد الله )
Great videos! Very clear and good commenting style!
Created Rectangle ^_^, Thanks for so simple & easy explanation.
Thanks a lot. This is SUPER HELPFUL
Is there a reason you are not deleting your pointers?? Won't these cause Memory Leaks? Why are you not using smart pointers instead?
Never use raw pointers, its a horrible design. Use smart pointers.
thank you very such a lot. this is one of the best tetorial i have ever seen .will done continue pleaaaaase
your tutorial is amazing! there is a one problem with my code which is that whenever i run it, the computer doent display the rectangle. There is non when i run the program, and do you know why???
jom: C:UsersadminDocumentsbuild-untitled-Desktop_Qt_5_7_0_MSVC2013_64bit-DebugMakefile.Debug [debugmainwindow.obj] Error 1
jom: C:UsersadminDocumentsbuild-untitled-Desktop_Qt_5_7_0_MSVC2013_64bit-DebugMakefile [debug] Error 2
12:15:14: The process "C:QtToolsQtCreatorbinjom.exe" exited with code 2.
Error while building/deploying project untitled (kit: Desktop Qt 5.7.0 MSVC2013 64bit)
Why am I getting this error?*
I copied your code and it doesn't run on Qt5.7
Why not do the same with Qt Quick? Is QML/Qt Quick "slow" for gaming?
First, very nice tutorial. Second, is there any particular reason you created those objects in the heap? They are not big to create in the stack.
Thank you! Your lessons are very good! I have a question about Qt. We have "QApplication a" and "QGraphicsView * view". How they are connected ? I mean how "QApplication a" knows about "QGraphicsView * view"?
For example, we have scene and rect and we do something like scene->addItem(rect) to let "scene" know about "rect".
But we don't do "a.AddView( view)" here! So I don't understand how "QApplication a" knows about "QGraphicsView * view".
Hello and thanks for best of the best tutorial on game programming in Qt! I don't understand one little thing – in 6:27 you say what first and second arguments of setRect() method define X and Y coordinates of rectangle in the scene. But why when you build application, rectangle was in the center of scene? And i try to change this value, but nothing has changed. More of them, when i trying set position by setPos() method, rectangle again stay the center position.
How i can create the scene with one rectangle, witch would positioning on the bottom of the scene (or view in this case). Thank you so much!
can i use visual studio or xcode to make this game?
Awesome tutorial! I'm having trouble and for some reason where it started in the second video and now I can't even do this tutorial because of it. When I tried inheriting from QGraphicsRectItem, Qt can't seem to find the class. The same goes for here now too where Qt is able to autocomplete <QGraphicsRectItem> but when I try to make a pointer for the class, it doesn't seem to compile or again Qt can't find the class. I've looked around, but for some reason there's no proper solution. I'm using Qt 5.8 and according to the company's documentation QGraphicsRectItem is still in the library and not deprecated.
mhmmm perfect
Thank you, really nice for Qt starters.
sir please i need to contact you regarding a problem that i arose when developing your breakout game, please let me know your email. mine is digitalfreak99@gmail.com
sir can you please explain me this statement in your breakout game.?
if (ball_y > block_y + y_axis && y_move < 0){
y_move = -1 * y_move;
}
what this y_axis && y_move <0 statemet do?
So much pointers for nothing.
Hey, is this tutorial series still up to date or are there any breaking changes?
great tutorial. But Im still trying very hard to install my qt in order not to stuck when creating project. No valid kit found. And Iv absolute no idea.
mersi abdullah jan !
Hello! I want to watch this tutorial but it is difficult because this does not have subtitles. Why? I now that it create automatically by YouTube
Where does the thumbnail come from? That's exactly the game I want to make.
Thanks a lot. I've been using Linux Mint, and i can't install any other game enignes including visual studio, except Qt. I should use this Pc for over a year, which is very bad. But now, i can make my own game due to your video. I really appreciate about your video.
Nice tutorials but when you create new objects are on the heap, you have to delete them after it's used (usually in the destructor) otherwise it cause memory leak
These tutorials saved my life and a huge number of nerve cells. Thanks a looooot! I mean for 6 years nobody could top it, wow
i think it's pronounced "cutie", nice tho, I never knew c++ gui programs were this ez
Hi! Is there any function to return in a matrix the pixels of the View?
Thanks
Is this tutorial still up to date ?
Aside from coding, you have the talent to explain things to make it simple and clear, what I hate about the other tutorials is that they dont explain to you what are lines of code all about, thank you for this tutorial and more power to your channel
Dont forget about parent widegts
This tutorial is excellent. Thank you!