Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 226 227 [228] 229 230 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 907198 times)

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3405 on: November 08, 2012, 12:03:22 am »

Depends on what you want to do and your skill level. You could learn SQL and set up a database if you are really keen, but that isn't required for the vast amount of things an amateur programmer will ever want to do.

Also, protip: If you are generating a map, and don't make major changes to it, then don't save the map, just save the seed and then use then to regenerate it.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3406 on: November 08, 2012, 12:13:25 am »

Does installing a game warrant setting up an SQL database? >.>
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3407 on: November 08, 2012, 12:15:48 am »

In a few cases, I guess. Can't think of any, but I'm sure there must be one for some huge game somewhere...
Most just use their own file format and use pretty simple file reader and writers to get stuff done.

EDIT: Also, before I forget, a while ago somebody in the creative forum was working on a roguelike game in python, or c++ or something that looked beautiful. Anybody remember it? What happened to that?

EDIT2: Never mind, found it. It was Lord Dullard's Cult.

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3408 on: November 08, 2012, 12:37:07 am »

Here is Liberal Crime Squad's saveload.cpp. This isn't a great example, but, as you can see, it's just a bunch of reads and writes. The only functions you really have to use are fopen, fclose, fread, and fwrite. (Note: LCSOpenFile and LCSCloseFile call fopen and fclose.)

stdio.h reference

I'm sure you could also use iostream if you wanted to. getline can be quite useful.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3409 on: November 08, 2012, 03:54:08 am »

Does installing a game warrant setting up an SQL database? >.>
Not that hard. Statically link/compile SQLite, it behaves exactly like a database, and stores everything in a "database file". It was the easiest C++ library I ever linked. It's like a save-file, but database-y! :)

Especially if you're working with huge worlds and you only want to load parts of it, this method can be useful. Setting up the interface (like what saves where in what field, setting up the tabledefinitions) etc can take some time, but after that you could just make a "object.save()" or "object.load()" method for every object, or parts of the map.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3410 on: November 08, 2012, 08:35:49 am »

I think C++'s fstream/ostream/istream are horridly inadequate for this usage.

Why is that? File management is generally an incredibly trivial process - I can't think of anything you'd want to do with a file that isn't covered by the fstream functions, honestly. What exactly are you trying to do that it's inadequate for?
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3411 on: November 08, 2012, 08:40:31 am »

Well, for starters, direct binary manip while it's in development means that if something is added or changes, old files can't be used easily. That's probably the same with state-saving.
I don't know, but manipulating plain text was pretty frustrating for me. :/ I might have been going around it the wrong way.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3412 on: November 08, 2012, 08:43:24 am »

Not exactly! The trick is to include the save version in the file, and keep every version of the file reader in the program. You read the first line of the save, telling you what version of save file you are dealing with, then pass the file over to the corresponding loader.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3413 on: November 08, 2012, 08:51:27 am »

Well, for starters, direct binary manip while it's in development means that if something is added or changes, old files can't be used easily. That's probably the same with state-saving.
I have no idea what you mean by this or what you are trying to do, but it sounds like madness. o_o

Quote
I don't know, but manipulating plain text was pretty frustrating for me. :/ I might have been going around it the wrong way.
C++ has plenty of parsers. Read the file into a data-structure, manipulate THAT, and when you're done with it send it back out to a file.

But mostly - yeah, it sounds like you're approaching it with the wrong mindset - trying to insert and remove those screws with a claw hammer is certainly an exercise in frustration, and may even work, but the problems aren't due to the inadequacies of the screw. :P

If you're more specific about one of the problems we might be able to help (Or maybe I'll notice when I get a chance to go through the code - Was gonna do that last night, but I saw a book, and ended up reading that instead. Stupid books, stupid addiction...)
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3414 on: November 08, 2012, 10:24:45 am »

Not exactly! The trick is to include the save version in the file, and keep every version of the file reader in the program. You read the first line of the save, telling you what version of save file you are dealing with, then pass the file over to the corresponding loader.
Eww.

Also, new version! Entity interactions! Also, enemies! Walking thingies that fall off platforms, and walking thingies that don't! If you walk into them, you die. If you land on them, you bounce! Also, the window is now resizable by changing the window size in the options menu and restarting.
Logged

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3415 on: November 08, 2012, 10:25:38 am »

Exactly how evil are global variables? The tutorial I followed mentioned to try to not use them, but didn't actually  explained why.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3416 on: November 08, 2012, 10:27:58 am »

Exactly how evil are global variables? The tutorial I followed mentioned to try to not use them, but didn't actually  explained why.
Very. Not ultimate evil, just very evil. You can usually do without, and if you can, you should.
http://c2.com/cgi/wiki?GlobalVariablesAreBad
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3417 on: November 08, 2012, 10:32:08 am »

Well, there goes plan Lazy.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3418 on: November 08, 2012, 10:34:13 am »

Keep in mind: everyone uses them, but everyone is also of he opinion that they are evil. If you have to go out of your way to avoid using them, by all means, use a global. The linked article (or mish-mash of opinions, really) points out good reasons to use them and bad reasons to use them.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3419 on: November 08, 2012, 10:37:28 am »

I'll just try to not use them for now. Well, except for input, as I am too lazy to make my functions actually read a file.
Logged
Pages: 1 ... 226 227 [228] 229 230 ... 796