Gaming with Xojo, seeking advice

Stuart, I also have one last question for you. Is there a way to not have to paint/draw the background constantly - similar to canvas.refresh(false). Being OpenGL, I don’t see any performance issues, but it seems like such a waste of CPU cycles to have to repaint that static background each time the frame renders.

Judging from your game I’d say you know enough to do this. Is there there something about ezgl that makes you unsure about modifying it? Here’s a quick stab…

add these properties to glTextureMine

Protected nameMap As Dictionary //name → bank index
Protected nameReverseMap As Dictionary //bank index → name

and while you’re at it make texNames Protected. Then add these methods

[code]Sub storeImageAlphaNamed(bankIdx As integer, imageName As String, p As Picture, pmask As Picture)

if nameMap = nil then //if first time used, just init
nameMap = new Dictionary
nameReverseMap = new Dictionary
else //check if this bank index is already mapped and remove
if nameReverseMap.HasKey(bankIdx) then
dim k As String = nameReverseMap.Value(bankIdx)
nameMap.Remove(k)
nameReverseMap.Remove(bankIdx)
end
end

nameMap.Value(imageName) = bankIdx //store new mapping
nameReverseMap.Value(bankIdx) = imageName

storeImageAlpha(bankIdx, p, pmask) //store data in texture bank

End Sub

Sub bindToNamed(imageName As String)

if (nameMap = nil) or (not nameMap.HasKey(imageName)) then return

OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, texNames(nameMap.Value(imageName)))

End Sub

Sub emptyNameMap()

if nameMap = nil then return //not inited

nameMap.Clear //empty
nameReverseMap.Clear

//and empty texture banks too?
End Sub[/code]

Updating storeImage with Alwyns code will take care and I don’t know when I’ll have time to really focus, if you update it that’d be great. I also want to fix how it handles alpha, passing as a separate picture was a quick hack for the demo and it’d be nice and more efficient to use the alpha in a single Picture.

glSurfacePlainCanvas does that. If you don’t call g.clearBuffers(fillColor, false) at the top of Paint you’re left with what’s already there (which may be frame buffer garbage). Try it out in the last ezgl, go to Window1.glSurfacePlainCanvas1.Paint, comment out g.clearBuffers and run that window. The sprites leave trails which reset with garbage when resized.

clearBuffers is optional to allow skipping it if you know you’ll be drawing the whole frame, but my intention was that the whole frame gets drawn each time either way. To get this optimization of only drawing dirty regions I don’t know enough to know how to do it pragmatically, I don’t think ezgl exposes the right tools. Perhaps glDrawPixels or something with frame buffers is better.

Nona the program is great. I can see the kids getting a big kick out of it, and of course, learning to type by touch.

Ha ha, I thought [deleted] was just Nona changing her name in civil disobedience of the name restriction thread that was active at the time. I see now ‘deleted’ is the status of her forum membership. She seems perfectly reasonable, I can’t imagine what infraction she made, or maybe she deleted it herself.

Anyways, Nona if you’re still watching these forums publicly you can contact me here because your game is fun and shiny and I’d like to continue helping where I can.

Stuart, like you, I was asking muself if it was because of the thread about the real name.
It’s sad “good” people have to leave this forum because of a decision against bad boys.

But we can speak about software protection, which, inmany case, are more inconveniant for correct people than for hackers.

The middle is a hard things to find.

Anyway, congratulation for this game. I’m sorry to don’t be able to follow the evolution.

As promised… tutorial on 2D sprites.