Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - AndyH

#61
Could you not load the entire file in to memory (eg: membanks) and then just look up the bits you need, make changes if required and write back the changes at the end when you are done?   It would probably be much quicker and the amounts of RAM on desktop's devices is not so limited as it used to.  Even if you planned to run on a GP2X, you've got quite a few Mb's to play with.

BTW, is it Cave Story you'll be editing by any chance :)
#62
Also take a look in the samples folder.  There is a MEMBANKS example in there, there are functions to create, read from, write to and free created memory at the byte level.  (be nice if these command were built in ... hint ;))

What I did in Mouth Trap was to use a membank that was the size of (LevelSize * numberOfLevels).  I load my level data into the bank using the normal file commands, then I can PEEK any byte in there.

I did use a TYPE which had some arrays and properties for a single level and I have a LOAD and SAVE level function to transfer the chosen level from the membank (eg: memBankPosition = levelToLoad * LevelSize) to an instance of the TYPE for easy access -it's simpler to access named arrays and element and property names than offsets in memory and if I decide to change the format of my level data it's easier to manage this way.

Be aware, especially on PPC and GP2X that have limited memory, that array elements take up four bytes each, so if you uses these exclusively instead of memory banks and you are not using 32 bit numbers then you will be using four times as much memory as you need.  You could compact four bytes worth of data into a single array element but I think that's just making it hard work for yourself.  

This is only an issue if you plan to use very large arrays, as the membanks may be more suitable (not always).  You've just got to weigh up what is more appropriate to use for the task at hand.  Hope that helps.   PS:  Yes I would like a file seek command too, good for simple database access :)
#63
Not a lot of screenshots considering there's a fair amount of entries!  Come on people.

Here's some screenshots of Ms Mouth Trap:

#64
Wow!
#65
I've not had any problems with local or global variables, and as Gernot says the Local scope in the main program (outside of any functions / subs) is working ok so the next place to check is your logic.

Have you tried single stepping through every line using the debugger, to see if the program flow is moving as you expect it to.  You can also watch the content of global and local variables.  You can use the debug command to print out data (eg: in types) at various stages of your program execution.
#66
Not able to run it here at work, but first the variable phase is not declared so GLB will make that GLOBAL.  I'm assuming that code is as-is and not in a function?  Perhaps LOCAL scope in main program is not working?  

Does it work if you do this?

Code (glbasic) Select
test()

FUNCTION test:
LOCAL phase
LOCAL time
LOCAL score

IF phase=0
time=2000
score=0
phase=1
ENDIF

IF phase=1
//show instructions
if key(enter)
phase=2
ENDIF
ENDIF

IF phase=2
time=time-1
//code for the game
ENDIF
ENDFUNCTION
#67
Cool, I was hoping it might be as there is a direct C++ equivalent.
#68
Would it be possible for GLB to support TRY ... CATCH blocks and THROW functionality for handling unexpected and expected errors?

This is not generally something you see in traditional BASIC's but you do get in most modern langauges (including VB) because it can help you to manage runtime errors quite easily.
#69
GLOBAL if you want to access the variable anywhere in your code.  Generally not a good idea to rely on globals too much, but they can be useful and you'll probably discover the best time to use them with experience.  Use LOCAL to declare variables that you wish have limited scope, as they'll reduce memory usage and can reduce the number of runtime errors you create for yourself as you'll have local blocks of functiontality.  Generally declare your locals in functions and remember to pass the local variables to other functions as required.  Remember locals will not exist outside of your functions or scoped blocks.
#70
Right - mine is in.  Good luck everyone!
#71
You've declared the score and time to be local in the IF phase=0 block.  They'll probaly cease to exist after the ENDIF.  I've not ever tried that, so I could be wrong, but based upon GLB converts the BASIC to C that would be my guess.  It's fairly common in most languages of that type (c, c#, etc)
#72
UTC midnight tonight is the deadline... what time is that in the UK?  Silly question but the clocks go change for summer time soon and I'm not sure exactly what time in the UK I've got to.
#73
GLBasic - en / Polyvector
2008-Mar-24
errr.... please never publish that game where you vector your bottom with poly's.

Thanks for the code Gernot, that will come in handy for me too.
#74
Will do, but I'll wait until after the 00:00 competition deadline tonight before I try that.  ;)
#75
I'm 50% certain I will have a playable version of my game submitted in time, but I've been wrong half the time and I'm not really sure about that.