Unhandled Error #258
Line: 7164 (in main module)
Invalid handle
Continue?
I'd recommend doing an _ECHO to a console window periodically and see what the image handle's value is.Not a bad idea, thanks.
Just for fun, I tried running your program with the development build v1.51 5e05664 and error occurs at line 7080 for me (also 28 warnings of unused variables) using menu option 3.
EDIT and the error came up immediately!
QB64 Version 1.5
Stable Release
From git 3043116
I've been looking at the code for half an hour, but I can't see through it. (why don't you use more arrays?)
Digging a bit further:Code: QB64: [Select]
That's generating several copies of imgBackground&, without ever freeing the previous iteration. Your program is leaking memory, like a lot. Check Task Manager while it's running.
I thought of suggesting you to do that call to _freeimage before making the copy, but the problem is exactly the line you're getting an error with now: SCREEN imgScreen& will lock the image as the current display image and will error if you try to free it.
Consider having a canvas image onto which you put all your layers, instead of setting SCREEN over and over.
It's usually 1- set screen once; 2- clear and reuse in a loop; 3- set a new SCREEN only if changes are made to size (if $resize is being used).
Your program is leaking memory, like a lot. Check Task Manager while it's running.
Not a bad idea, thanks.
Dumb question though, how do you open a second console window and _ECHO to it?
I've never done anything like that in QB, but I can see that would be very helpful while debugging.
Thanks again.
To make a console in QB64 you need to use the metacommand $CONSOLE. You toggle it ON or OFF with _CONSOLE ON or _CONSOLE OFF. _ECHO allows you to output to the window. So _ECHO "Window Handle: "; STR$(imgScreen&)I'm definitely going to try this, as soon as I am back on the PC.
I am so clueless. What's a canvas image? I thought they were all just images?
The reason I set SCREEN above, is to simply unlock the imgScreen& so I can _FREEIMAGE it, so when I copy the layers onto it, there aren't all those copies.
I am really confused.
Would you maybe be able to post a simple example or point me to one?
Thanks again
UPDATE:
Maybe I am using _CopyImage when I really need to be using _PutImage ... When I get back on the computer I will look that up. Thank you all for being so kind and patient with one so thick headed.
Yes, _PUTIMAGE is your friend. You should only have to set SCREEN once and then put images on it, CLS, _DISPLAY, etc.
I think what Fellippe is referring to as a "canvas" would be like the image 'underlay' in the crude example below:
To make a console in QB64 you need to use the metacommand $CONSOLE. You toggle it ON or OFF with _CONSOLE ON or _CONSOLE OFF. _ECHO allows you to output to the window. So _ECHO "Window Handle: "; STR$(imgScreen&)
@madscijr
What is the state of art of your program?
Yeah, I think he's just asking if you have an update.
I'm not sure what you mean.Thanks madscijr you have showed me that the same phrase has two different meanings in English and in Italian.
I wouldn't say it's the state of THE art, if that's what you mean, lol.
@madscijr
about game... fine, I see you prefer to use black color for background of images.
I you're interested to use different colors as background and you want don't cover background image of the screen with the background of the image by _PUTIMAGE I suggest to you to give a look to _RGBA32 colors and to the related commands for Alphacolor tecniques here http://qb64.org/wiki/Keyword_Reference_-_By_usage#Colors_and_Transparency (http://qb64.org/wiki/Keyword_Reference_-_By_usage#Colors_and_Transparency).
Thanks madscijr you have showed me that the same phrase has two different meanings in English and in Italian.
What Bplus says about my message is what the state of the art meaning into italian language... at what point is your work
and here I have learned what this phrase meaning in English language and its evolution from 1800 to now.
https://www.linkiesta.it/2016/09/lo-stato-dellarte-dallinglese-allitaliano-spiegato-dalla-crusca/ (https://www.linkiesta.it/2016/09/lo-stato-dellarte-dallinglese-allitaliano-spiegato-dalla-crusca/)
It is always a pleasure to learn something new.
One thing you might look into doing that might help the read-ablitiy of your program is creating a data file and loading that rather than setting all the data with in your main program.
For example:Code: QB64: [Select]you have over 1000 lines of your main program made up of this data alone,
arrNPC(1, 1).TileNum = cTileChild1% arrNPC(1, 1).Frequency = 100 arrNPC(1, 1).Behavior = "it" arrNPC(1, 1).Talk = "Are you going to save the people?" arrNPC(1, 1).Yell = ""
if you moved all that to a second program that saved it to a file you could load from that file with 3 lines as followsCode: QB64: [Select]and there you save over a 1000 lines of code, reduce the length of your main program so it is easier to navigate and read, while too allowing easier changing of data at a later date by having it all in one location rather then scattered through out the main code.
You can do that with any BULK data that you use within your game, which could probably reduce your main code by several thousand lines and tens of thousands of bytes.
Level=1
Name=Child
TileNum=cTileChild1%
Min=1
Max=1
Behavior=it
Talk=Are you going to save the people?
Yell=
Level=1
Name=Child
TileNum=cTileChild2%
Min=1
Max=2
Behavior=it
Talk=Please save us from the monsters!
Yell=
A good example of this is my Dragon Warrior clone, if you check it out you will see I have 2 program source files;
--DW1_FullSource.bas which is the main program,
and a second
--DRAGONWARRIORDATA.BAS which is all the data for the game.
Your project looks very interesting though, can not wait to see it finished.