Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / For those of you having trouble with saving/loading in your games

Author
Message
Delfir
20
Years of Service
User Offline
Joined: 28th Aug 2004
Location:
Posted: 26th Nov 2005 14:43 Edited at: 26th Nov 2005 15:32
Before I get to the code (below), I need to explain a few things. This program will not run without a media file called "square.bmp". Just go into MSPaint, and make a 26*26 pixel square and save it as "square.bmp" in the same directory as the program. What this program does is, allows you to move the square around with the arrowkeys, and when you press "s" saves the square's x and y positions. When you end the program and press "l", the program loads your previous save file, and the square will be right where you saved it last time. Seems simple now, but it will help in the long run (for those of you who plan on making long games and want save files).



edit: thanks

Legendary>Heroic>Normal>Easy
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th Nov 2005 14:51 Edited at: 2nd Dec 2005 17:48
Please edit your post and put the code between [[/b]code[b]] and [[/b]/code[b]] tags.
[edit] thank you...

A basic introduction to the basic of file saving and loading. Pretty good.



Immunity and Annihalation makes Immunihalation...
Delfir
20
Years of Service
User Offline
Joined: 28th Aug 2004
Location:
Posted: 26th Nov 2005 15:37
Sven, did you run the program?

Legendary>Heroic>Normal>Easy
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 26th Nov 2005 17:08
To be honest, I did ...

Immunity and Annihalation makes Immunihalation...
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 28th Nov 2005 09:00
users would find it more easier if you made save/load functions rather than embeded them into the main source, and instead of making the users save a blank image just for the sake of running your code you could have just used the box command to draw a box on the screen.

does what it says on the tin though..


Delfir
20
Years of Service
User Offline
Joined: 28th Aug 2004
Location:
Posted: 29th Nov 2005 04:55
@dark coder: let me let you in on a little secret. I'm crappy at making functions. I fail every one I try to make. Now I am eternally damned to writing my source over and over again instead of using convenient functions where the parameters just need to be slightly changed. Therefore, I have to embed EVERYTHING I do into the source cluttering my poor, poor code.

-Delf

Legendary>Heroic>Normal>Easy
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 2nd Dec 2005 17:50
Quote: "users would find it more easier if you made save/load functions"


I don't agree. Functions aren't able to pass multiple variables at a time. Unless you're working with globals, wich aren't available in DBC anyway.

I would prefer subs:

Immunity and Annihalation makes Immunihalation...
UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 5th Dec 2005 01:21
Quote: "wich aren't available in DBC"

Uh...There are arrays though...
They are globals.

If you want a variable instead of an array global, use Variable(0), or whatever.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Dec 2005 19:35
Quote: "If you want a variable instead of an array global, use Variable(0), or whatever."


I don't know but don't you think it'll be easier to create subs then?

Anyway, I'm gonna leave it as it is.

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2024-11-23 10:58:19
Your offset time is: 2024-11-23 10:58:19