Finding decent *working* example code

BlitzMax Forums/BlitzMax Beginners Area/Finding decent *working* example code

Rydan77(Posted 2006) [#1]
Hi, Just purchased Blitzmax the other day and it looks great so far. Only thing im finding dissapointing is that whenever I find any code of interest to learn from like - tilemap/scroll demo or a space invaders code demo the thing wont compile. cause it has bugs in it. I have used blitzplus a little, but don't know enough about blitzmax to correct the errors im getting from the compilier. If someone out there could point me to some working code for either tilemap scroller, or simple space invader /pacman code to read and learn from, that would be greatly appreciated thanks.


H&K(Posted 2006) [#2]
Hi,

Its normaly not because the code has bugs in it, its normaly because the code is from a previous version.

Skid went through the code archieve the other week and changed things so that they work with 1.22

If you post the error messages you are getting on this thread, we can tell you how to change things for 1.22 normally its only the garbage collection, the import files and the GL commands


Rydan77(Posted 2006) [#3]
Oh ok, thanks mate. Well I'm using 1.22 and loaded a demo prog called maxinvaders by Jason Brasier.

First Error that is: Unable to convert from TStream to Int


H&K(Posted 2006) [#4]
Oh come on Play the game, at least post the line with the error.

Also I was under the impression that Maxinvaders was a finished product from http://www.sos-software.co.uk/ Were was the demo so I can download it and look?


Rydan77(Posted 2006) [#5]
i downloaded it again and but from another site (couldn't remeber first site i got it from) but it seems to work now, sorry for the bother, might have been a corrupted download or something or missing files.


WendellM(Posted 2006) [#6]
Unable to convert from TStream to Int

Glad you got it working in that particular case, but you'll see this sort of thing with older code. It used to be permitted to have Int handles for images, streams, and such, but that became more strictly enforced when auto-garbage collection became possible.

If you see it in the future, just change the declaration of the variable to match what BlitzMax is complaining about and you should be fine. For example, an old program might have:
Strict
Local pic = LoadImage("somepic.jpg")
where pic defaults to Int and you get an "Unable to convert from 'TImage' to 'Int'" compile error. You can fix it with:
Strict
Local pic:TImage = LoadImage("somepic.jpg")

Another one that you'll sometimes run into is the use of "FlushMem." Just eliminate all uses of FlushMem and you should be fine (garbage collection now defaults to automatic, so FlushMem was eliminated).

You can find these changes and others in "Versions.doc" (in the "Program Files\BlitzMax" folder for Windows). Maybe not the most exciting reading ever, but useful. :)


Garrett(Posted 2006) [#7]
Ehehehehe........ I should have asked about this too, as I ran into this a lot
when importing BB files from the code archives.

Learn something new everyday :-)

-Garrett


Rydan77(Posted 2006) [#8]
Ahh yes, have seen flushmem in some examples and have deleted it before and the code worked fine. Thanks for the 'Unable to convert from timage to Int tip. Now that I have got this space invaders code working, it should keep me busy for a while, and hopefully come up with my own first space invaders version sometime soon:)


Rydan77(Posted 2006) [#9]
Ahh btw another one I come across in samples is: Unable to calculate tex size


xlsior(Posted 2006) [#10]
Ahh btw another one I come across in samples is: Unable to calculate tex size


What kind of machine/video card are you using?

It could be that:

1) The program is trying to run in full screen mode and your video card doesn't do full screen OpenGL
2) The program is trying to run in windowed mode and your video card doesn't do windowed OpenGL
3) The program is trying to run in windowed mode and your video card doesn't support 3D accelerating in the bitdepth used by your desktop
4) The program is trying to run in full screen mode and your video card doesn't support 3D acceleration in the bitdepth requested by the program
5) could be that either your DirectX or OpenGL drivers are broken

...for starters.


Grey Alien(Posted 2006) [#11]
yeah the bugs are due to the code being written in previous versions and can usually be fixed easily - just post here and people will help you. My BlitzMax Game Framework has working source code for an entire game called Attack of the Mutant Greys, checkout the dmeo if you have time.


JazzieB(Posted 2006) [#12]
Oh ok, thanks mate. Well I'm using 1.22 and loaded a demo prog called maxinvaders by Jason Brasier.

First Error that is: Unable to convert from TStream to Int


Hmm, I thought I changed all of my code examples to work on versions after the removal FlushMem, etc. Looks like something else changed without me realising.

The offending line that gave you the error above is
Local configFile=ReadFile("config.ini")
..which should be
Local configFile:TStream=ReadFile("config.ini")
in the latest build of BlitzMax.

I'll check through my other stuff and upload any updates over the weekend.


H&K(Posted 2006) [#13]
Unable to calculate tex size


This is very often because you are Creating a graphic Object but not selecting it

If you use CreateGraphics then you must also use Setgraphics

An example
SetGraphic (CreateGraphics( 640,480,0,60,GRAPHICS_BACKBUFFER | BGL_DEPTHBUFFER ))


Jesse(Posted 2006) [#14]
I wrote a space invaders when I first got BMAX about a year ago to learn it. It uses graphics from different arcade games. It is not complete but is playable. if anybody is interested, I can email the source code. It is not well documented but I don't think its that hard to follow. you can download the executable from here:
http://www.gamedev.net/community/gds/viewentry.asp?projectid=411660


deps(Posted 2006) [#15]
Unable to calculate tex size

This can also happen with Intel drivers.


Rydan77(Posted 2006) [#16]
xlsior: yes, it seems that after running a couple more programs it does seem I have some opengl issues. The computer im running is a bucket -a celeron 730mhz with an old tnt2 card (It's my girlfriends computer) so i dont expect wonders from it.

H&k: thanks, it will take me a while to learn what all the errors mean.

grey: great little game, tried your demo works great, but if I select opengl, the game has a shitfit and takes me back to windows.

So it seems until I can afford to update this pc, or better yet get a new pc, I should stick to projects that use directx.

jesse: I just downloaded and tried your space invaders game and got 'Unable to calc text size' and it shut down, so im guessing it was written in opengl.

thanks for your input guys, appreciate it. :)


Jesse(Posted 2006) [#17]
I updated the version in directX
and modified it a little I made two version the original
and the updated version.
I am working on creating a high score table
it will show up in the game but it is not implemented yet.
here is the source code of the updated version
if you are interested:


but you have to download the updated version from here for it to work:
www.gamedev.net/community/gds/viewentry.asp?projectid=411660


Rydan77(Posted 2006) [#18]
Jesse: thanks for the update, I put the new source code into the game directory and it works a treat now. Cool game btw :)


Grey Alien(Posted 2006) [#19]
Rydan77: thanks. Yeah it switches to OpenGL and has various protections in place for PCs with no OpenGL, but guess what, none of them work, it just bombs back to windows ho hum. I'll look into more protction soon.