Unsolved Visual representation of Connect Four
-
So basically all I'd have to do is create the board by duplicating a single piece of drawing of the grid n×m times, then adjust their coordinates to fill the window, then create two different colored elipses, then whenever I click on a certain region of the scene, defined by the columns of the grid, then play the animation of the gems falling in place, while adjusting the model of the game accordingly?
Sounds easy on paper, so I'll definitely give it a go down the line, but for now I will probably stick to the caveman style of creating it with buttons, because I really need to dive deeper into the whole painting aspect and the Graphics View framework, let alone animating it.
Still, thank you very much for your help!
If you don't mind, I will not close this post yet, because I might need to check back for further questions, and I would not like to flood the forums with them.
-
@LxKiss
Hi
Well its able to handle huge object amounts of objects and i know people made games with it
so hence i suggested it. So yes you would have a data structure with your items and
would manipulate their location as they are being dropped.btw i came across this made in QML
https://github.com/csgib/AngryMom
Didnt try it yet though. -
Hey there once again.
So I've came across this class called QPropertyAnimation, which in my mind would be perfect, because all I want to achieve is just to make the afformentioned gems fall vertically down, then maybe throw in a bounce effect once they react their end destination.
However, my game screams for a grid layout, but I cannot make animations work inside a layout.
I've created a QLabel, and I've set it's pixmap to my desired image, but I cannot get it to work. Is it due to it being within a layout, or am I missing out something?
-
@LxKiss
Hi
Any widget inside a layout cannot be moved at will. Layout controls location/size
So nope, QPropertyAnimation wont work on widgets in a layout.
But calculating the grid by hand is not super complicated.? -
Obviously not, but how would I treat the main window of the application as a "canvas" for the images?
For instance, if I declare two labels with pixmaps assigned to them, then invoke their show method, they show up in two different windows, as they should.
So without layouts, how do I get around that?
-
@LxKiss
Hi
When you create the QLabel simply assign centralWidget() as parent
and they will be inside the center of mainwindow.
like
new QLabel("hellO", centralWidget());You could also make a custom widget to encapsulate the handling of the QLabels and use
that on on mainwindow.
How do you handling the clicking on the Q Labels? -
Well, I've thought about handling mouse events, but for now I'll just place as many buttons as there are columns above the board, in a layout.
As far as using centralWidget() goes, I have never used the mainwindow class generated by default, I've always created new widgets, then used them in the main.cpp by creating a new instance, then using the show function, so how would I make it available in a new class, as you've suggested?
-
@LxKiss
You mean how to create a new subclass Like GemBoard and let it handle the labels? -
No, I mean I was unable to access centralWidget() in my own class.
-
@LxKiss
Oh, but if are QWidgets, they dont have centralWidget() then simply use the
widget as parent.
Like
(in main)
Mywidget wig;
QLabel *lab = new QLabel("hellO", &wig);
(Lab will then be inside Mywidget )