View Full Version : PuzzleGame
Hi,
Here is a little Puzzle Game.
I have got some difficulties with the speed.
The game is not so fast here.
I had to take out some things, for optimizing
the speed.
Nevertheless, it is very neat to play.
What do you have to do in this game, pick up emeralds.
In Twenty five Maps can you be the master.
Simple rules makes your life easier and happier.
The first rule, hurry up in order to get more time.
More time = more points.
Second rule, stay healthy and touch no monster.
More rules are not necessary.
You can push stones, to right and to left.
You can drop a stone on the heads of the monsters.
You use the arrow keys for movement of your hero.
You can suck an emerald or ground by pressing control key
and an arrow key. First press the left control key.
Press an arrow key in the direction, where you want to suck.
In some Maps, you must lead the green peperoni against a green slime bloc.
Every peperoni owns an emerald in his pocket. With a collision against a bloc,
he will lose it.
Do not forget to run into the exit if you are ready.
You start a Map by pressing return key. Your selector must to be on "LEVEL".
Take the arrow key for moving your selector "up/ down/ right/ left".
In the ohter options you can read if you are there.
It seems that Thinbasic becomes more complicated in its new version.
"End iF : End iF" does not go.
When i forget to use a variable without declaration, then goes Thinbasic out without a word.
Such an error to find is very difficult and needs too much time.
GetAsyncKeyState is good, but we have no key that gives me back the "ASCII CODE" and has no repeat.
Please not: that is to find in the console !
When i open a window screen with TBGL, then are the mouse coordinates in the upper left corner of the screen not 0, 0.
Can it be that Thinbasic is overloaded with commands, and thereby the speed is missing ?
best regards......
Peter
Petr Schreiber
20-02-2009, 15:30
Hi Peter,
the game is perfect. I remember playing something like this called "Dynamite Joe", falling rocks are great gameplay feature :)
I would like to help you optimizing, but without seeing the code it is very difficult.
When i forget to use a variable without declaration, then goes Thinbasic out without a word.
Could you show us code sample?
Following displays correctly "Variable not defined or misspelled Keyword", including the suspicious variable (b):
dim a as long
a = b * 2
When i open a window screen with TBGL, then are the mouse coordinates in the upper left corner of the screen not 0, 0.
Why do you think so? Try to run attached code, on my PC it shows 0,0 for upper left and 639,479 for lower right corner in 640x480, which seems quite standard to me?
For key without repeat use tbgl_getWindowKeyOnce in TBGL.
Thank you,
Petr
P.S. Launching level 11 and 12 ends the program
Petr Schreiber
20-02-2009, 15:50
Little advice,
if you do not want to make window resizeable, use %TBGL_WS_DONTSIZE style.
If you want to make it possible to sync graphics with resizing, use "virtual vector resolution" by calling TBGL_RenderMatrix2D(0, 479, 639, 0 ) for example. That will make upper left corner 0, 0.
Hope it helps,
Petr
Michael Hartlef
20-02-2009, 16:47
Can it be that Thinbasic is overloaded with commands, and thereby the speed is missing ?
Hi Peter,
can you explain this more detailed? Did you noticed a slowdown in speed during the last releases of thinBasic?
ThinBasic is interpreted and so will be allways slower than a compiled language. Also it depends on what you do
with it. I personally try not to use to many function calls to external DLL's. I noticed that having the same code
in a thinBasic module is called much faster than a call to the same code but inside an external DLL. There are so
many tricks to speed up things. It's hard to help you here without a look on your code.
Michael
ErosOlmi
20-02-2009, 16:53
"End iF : End iF" does not go.
I will check that one
When i forget to use a variable without declaration, then goes Thinbasic out without a word.
Such an error to find is very difficult and needs too much time.
Can you please give me few lines of code where variable checking is not working?
If confirmed, I will fix it immediatelly.
GetAsyncKeyState is good, but we have no key that gives me back the "ASCII CODE" and has no repeat.
I will try to think about it. There are many different ways we can handle repetition. Correct way should be to use callbacks events but without knowing source code of you game (callbacks usage or infinite loops) I can just guess.
Anyhow, thanks again for this nice game!
Eros
MouseTrap
20-02-2009, 18:03
When i forget to use a variable without declaration, then goes Thinbasic out without a word.
Could you show us code sample?
Following displays correctly "Variable not defined or misspelled Keyword", including the suspicious variable
This may be what I experienced, in that an error message can appear and be hidden in the task bar.
I spent hours thinking that TB was silently failing when it wasn't :roll:
perhaps It needs an option to have the error message be modal/nonmodal.
ErosOlmi
20-02-2009, 18:14
Ok, I can understand that the error message is trapped but window is hidden by other windows.
Problem is that I cannot know if script has a window to which to attach a modal error message dialog. Also script can have many different windows open at the same time so not easy to know how attach. Also there are scripts that do not create any window.
What I can do is to put runtime error dialog at the top and also flash its icon in shell toolbar
I will check what I can do.
Eros
ErosOlmi
20-02-2009, 19:21
"End iF : End iF" does not go.
Fixed. Will be present in next release.
Hi,
thank you Eros.
Try this update please !
Does it go ?
Hi Petr,
maybe it is my game engine. Come and see for yourself !
I did found a way to optimize the speed.
I will send it as update for my Puzzle Game soon.
If the window becomes maximized, and we have a
resolution of 640x480, i ask me whether the people, which
have a Flat screen can see something ?
Petr Schreiber
20-02-2009, 20:26
Hi Peter,
I would like to answer all your questions precisely, but without code it is bit of magic :)
But here I go:
maybe it is my game engine. Come and see for yourself !
It is highly probable - do you use TBGL_MouseGetPosX, TBGL_MouseGetPosY at all?
Because they return -1 in case mouse is outside window, which is not the case for example you posted ... so I presume you are not using those functions?
Your program shows global coordinates of mouse.
If the window becomes maximized, and we have a
resolution of 640x480, i ask me whether the people, which
have a Flat screen can see something ?
If you will follow my advice with TBGL_RenderMatrix2D, yes they will see correct output.
Unique feature of TBGL window is, that when you maximize, it still keeps the proportions, so graphics will not became stretched.
See for yourself:
'
' Persistent "virtual" resolution
' Petr Schreiber, started on 02-20-2009
'
Uses "TBGL"
FUNCTION TBMAIN()
LOCAL hWnd AS DWORD
LOCAL FrameRate AS DOUBLE
' -- Create and show window
hWnd = TBGL_CreateWindowEx("Keeping the aspect ratio", 640, 240, 32, %TBGL_WS_WINDOWED or %TBGL_WS_MAXIMIZEBOX or %TBGL_WS_CLOSEBOX )
TBGL_ShowWindow
' -- Resets status of all keys
TBGL_ResetKeyState()
' -- Main loop
While TBGL_IsWindow(hWnd)
FrameRate = TBGL_GetFrameRate
TBGL_RenderMatrix2D(0, 239, 639, 0)
TBGL_ClearFrame
TBGL_BeginPoly %GL_LINES
TBGL_Vertex 0, 0
TBGL_Vertex 639, 239
TBGL_Vertex 0, 239
TBGL_Vertex 639, 0
TBGL_EndPoly
TBGL_BeginPoly %GL_QUADS
TBGL_Vertex 319-100, 119-50
TBGL_Vertex 319+100, 119-50
TBGL_Vertex 319+100, 119+50
TBGL_Vertex 319-100, 119+50
TBGL_EndPoly
TBGL_DrawFrame
' -- ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
END FUNCTION
Petr
MouseTrap
20-02-2009, 21:26
If the window becomes maximized, and we have a
resolution of 640x480, i ask me whether the people, which
have a Flat screen
can see something ?
@Petr
I think that's a reference to the fact that LCD monitors don't do res <= 640x480
I tried your example with 640,480 and fullscreen flag on my crt monitor and It tries to set the refresh rate at 250. Obviously the monitor cant handle that and freaks out. Is there a way to specify the vsync when a graphics context is created?
I think this is the best game you've made so far peter. :eusaclap:
It reminds me a bit of a game I saw on the C64 called Boulder Dash (http://www.youtube.com/watch?v=Nh9_bOob484).
thank you for the comment Matthew.
Michael Hartlef
20-02-2009, 22:41
Hi Peter, ths is a very nice game you made there and it plays fine on my system.
Just a side question. I saw that you also make versions of your games with Brutus2D. Why are you doing this?
Hi Michael,
Why ? I'm a member there.
I have a good time programming with Brutus2D.
That's really a fine Basic dialect !
That's easy and fast and sympathetic.
By the way: I am programming in all Computer languages and dialects !
Peter.
Michael Hartlef
21-02-2009, 00:08
I was just curious why to create the same game with 2 different languages.
Petr Schreiber
21-02-2009, 00:19
Hi MouseTrap,
this is important information to me.
Could I ask you to repost this as bug along with the example which produces this behavior, graphic card used and monitor driver (generic/specific)?
Because this should never happen - I query driver for maximmum frequency supported ( to avoid 60Hz eye bleeding on CRT).
V-Sync can be manipulated via TBGL_UseVsync.
Thank you
If the window becomes maximized, and we have a
resolution of 640x480, i ask me whether the people, which
have a Flat screen
can see something ?
@Petr
I think that's a reference to the fact that LCD monitors don't do res <= 640x480
I tried your example with 640,480 and fullscreen flag on my crt monitor and It tries to set the refresh rate at 250. Obviously the monitor cant handle that and freaks out. Is there a way to specify the vsync when a graphics context is created?