Description: This is a Sokoban game entirely written in QML + Javascript. Therefore Qt 4.7 or higher is required. No code must be compiled, you only have to extract the source and run "qmlviewer qmlsokoban/qml/main.qml" (note that in some Linux distributions like Ubuntu qmlviewer must be installed separately).
The purpose of the game is to move the diamonds to the green spots by letting the warehouse keeper push against the diamonds. You move the warehouse keeper using the arrow keys or by clicking/touching the screen.
I have written this game because (1) I missed KSokoban from KDE 3 and (2) I wanted to learn QML. Although the levels and the graphics are copied from KSokoban, the implementation is mine.Last changelog:
version 0.7 (2011-12-16): - add panel to select level collections (the list of collections is hardcoded)
Hi Glad,
Firstly, I'd like to congratulate you. You have done a very good job until now!
I've found a little bug in the level parser. When you have the itemMan over an goal point in the map (the '+' character) you put everything on the right place but the variable numOfGoals must be increased.
The behavior is, the last treasure block is not deleted when you recreate the level or go to another one.
Fix: Put ++numOfGoals; in the case '+'... (line 107 of game.js)
Very nice job!
The orientation still isn't working :\.
It still complains that there is no such variable as runtime.orientation.
Also, the "Press a key.." text doesn't fit in the screen in Portrait (first and last letters).
By the way, the buttons on the bottom seem to mess up sometimes. They will stop working and if I click them too fast I seem to get a weird result that looks like two maps in one.
The text-fitting problem should be solved now. It is strange that runtime.orientation is not recognized; the Qt doc (http://doc.qt.nokia.com/4.7/qmlviewer.html) states that this variable also exists on Symbian devices. Does the two-maps-in-one problem remain when you stop pressing the buttons, or does it only appear temporarily until the latest level is completely loaded?
Well it seems that the 'runtime' variable is dependent on the QMLViewer.
It is definitely not included in the default QMLViewer 'wrapper' for QML files in Qt-Creator.
Although, by adding QtMobility and a few lines of code I was able to replicate the 'runtime' variable. This is all outside of your QML project.
It should work fine then.
Hey,
I just tested this game out on my phone.
In portrait mode everything appears fine but the map is small because screen is narrow.
If I rotate in to landscape mode, I can only see the top of the map (in bottom corner of the screen). So there is an issue with rotation.
However, if I start the game in landscape mode, everything looks BEAUTIFUL!
I have provided a picture:
http://img594.imageshack.us/img594/2563/imgp0512f.jpg
Of course my phone has no keyboard, so I can't control the man. This would be solved by using a N97 or E7. But everything else works fine.
Good work.
Thanks
Oh nevermind about the Portrait/Landscape thing. Easily fixed by setting viewer.setOrientation(QmlApplicationViewer::LockLandscape);
before compile time in the QML viewer.
Thanks for testing this game on a mobile phone. I don't have any smartphone, so I cannot do the testing myself. Version 0.3 should solve the orientation problem and you should now be able to play the game too (I suppose that the QML element MouseArea works on a phone by touching the screen). Could you tell me what happens with the buttons in portrait mode (they are probably too wide to go on one line and still be all visible)? Is there any animation when changing from portrait to landscape mode? Do the inverted portrait and landscape mode work?
I can move the man by touching where I want him to move now!
That works fine.
The rotating still has an issue. It doesn't animate and the text and map doesn't fit in to the screen (360 pixels wide).
I think it's best to just lockLandscape in the QML Viewer as the screen is quite narrow. That works fine.
By the way, I made a little modification to the start screen.
id: startInputHandler
I changed the Item to a MouseArea and then, to prevent issues while playing, I set visible: screen.state != "playing" (might need to change this for levelwon too) and onClicked: Game.startNewGame()
I changed the Text to "Touch screen to start" but of course that's just for phone.
I think I might know your problem for orientation.
For this line:
"state: (runtime.orientation == Orientation.Landscape"
It complains 'Can't find variable: runtime'
I have compiled a SIS that locks Landscape orientation. Should work on all Symbian devices that support Qt (S60v3, S60v5 and Symbian^3). Tested on 5800 and N8.
http://www.wikiupload.com/Y5D429LRV8BPIVH
Thanks for the continuing support. Fixing the orientation to landscape is not an option because for some levels (such as level 39) the screen should rather be in portrait mode. I made another attempt at letting the level resize when the orientation changes. Could you try it out?
hi, this game looks great - is there any chance someone could make a current build for symbian available? i tried to figure out how to do it myself but being on a 32bit mac i couldn't find a way.
many thanks!
Ratings & Comments
12 Comments
Hi Glad, Firstly, I'd like to congratulate you. You have done a very good job until now! I've found a little bug in the level parser. When you have the itemMan over an goal point in the map (the '+' character) you put everything on the right place but the variable numOfGoals must be increased. The behavior is, the last treasure block is not deleted when you recreate the level or go to another one. Fix: Put ++numOfGoals; in the case '+'... (line 107 of game.js) Very nice job!
Hi, thanks for the bug-report and for your nice words!!! The bug is fixed in version 0.4.1.
The orientation still isn't working :\. It still complains that there is no such variable as runtime.orientation. Also, the "Press a key.." text doesn't fit in the screen in Portrait (first and last letters). By the way, the buttons on the bottom seem to mess up sometimes. They will stop working and if I click them too fast I seem to get a weird result that looks like two maps in one.
The text-fitting problem should be solved now. It is strange that runtime.orientation is not recognized; the Qt doc (http://doc.qt.nokia.com/4.7/qmlviewer.html) states that this variable also exists on Symbian devices. Does the two-maps-in-one problem remain when you stop pressing the buttons, or does it only appear temporarily until the latest level is completely loaded?
Well it seems that the 'runtime' variable is dependent on the QMLViewer. It is definitely not included in the default QMLViewer 'wrapper' for QML files in Qt-Creator. Although, by adding QtMobility and a few lines of code I was able to replicate the 'runtime' variable. This is all outside of your QML project. It should work fine then.
Hey, I just tested this game out on my phone. In portrait mode everything appears fine but the map is small because screen is narrow. If I rotate in to landscape mode, I can only see the top of the map (in bottom corner of the screen). So there is an issue with rotation. However, if I start the game in landscape mode, everything looks BEAUTIFUL! I have provided a picture: http://img594.imageshack.us/img594/2563/imgp0512f.jpg Of course my phone has no keyboard, so I can't control the man. This would be solved by using a N97 or E7. But everything else works fine. Good work. Thanks
Oh nevermind about the Portrait/Landscape thing. Easily fixed by setting viewer.setOrientation(QmlApplicationViewer::LockLandscape); before compile time in the QML viewer.
Thanks for testing this game on a mobile phone. I don't have any smartphone, so I cannot do the testing myself. Version 0.3 should solve the orientation problem and you should now be able to play the game too (I suppose that the QML element MouseArea works on a phone by touching the screen). Could you tell me what happens with the buttons in portrait mode (they are probably too wide to go on one line and still be all visible)? Is there any animation when changing from portrait to landscape mode? Do the inverted portrait and landscape mode work?
I can move the man by touching where I want him to move now! That works fine. The rotating still has an issue. It doesn't animate and the text and map doesn't fit in to the screen (360 pixels wide). I think it's best to just lockLandscape in the QML Viewer as the screen is quite narrow. That works fine. By the way, I made a little modification to the start screen. id: startInputHandler I changed the Item to a MouseArea and then, to prevent issues while playing, I set visible: screen.state != "playing" (might need to change this for levelwon too) and onClicked: Game.startNewGame() I changed the Text to "Touch screen to start" but of course that's just for phone.
I think I might know your problem for orientation. For this line: "state: (runtime.orientation == Orientation.Landscape" It complains 'Can't find variable: runtime' I have compiled a SIS that locks Landscape orientation. Should work on all Symbian devices that support Qt (S60v3, S60v5 and Symbian^3). Tested on 5800 and N8. http://www.wikiupload.com/Y5D429LRV8BPIVH
Thanks for the continuing support. Fixing the orientation to landscape is not an option because for some levels (such as level 39) the screen should rather be in portrait mode. I made another attempt at letting the level resize when the orientation changes. Could you try it out?
hi, this game looks great - is there any chance someone could make a current build for symbian available? i tried to figure out how to do it myself but being on a 32bit mac i couldn't find a way. many thanks!