Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 629 630 [631] 632 633 ... 796

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

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9450 on: May 03, 2016, 03:39:50 pm »

Saving (or copying) a struct just directly copies all member variables. This does not include following pointers and saving out dynamic memory. You need to write custom loader/savers if you want to do something like that. The issue is that only the pointers are saved, i.e. the numerical memory addresses. When the struct is loaded, none of that data necessarily exists any more, and the values in the pointers are effectively meaningless.

To save (or copy) a struct/class which uses dynamic memory, you need to write custom load/save code (or a copy-constructor, for copying), e.g. save out the non-pointer parts, then save out the dynamic data. Then, on loading, create the struct, allocate new memory for the dynamic data, then set the pointer correctly for the newly allocated memory.

The example which uses a set-sized char array avoids the problem, because the data is directly embedded in the struct, which is the bit you told it to copy.
« Last Edit: May 03, 2016, 04:00:31 pm by Reelya »
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9451 on: May 04, 2016, 12:28:47 am »

Just spent almost a half an hour wondering why my pthread implementation for one of my classes wasn't working right... before realizing that I was trying to run it on my Windows desktop instead of my OSX laptop. Swapped the code over and and everything runs perfectly on the first try.
*facepalm* :P
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9452 on: May 04, 2016, 09:21:35 am »

Why do people release things and then not document them? More importantly, why do they write half of a rambling, utterly useless wiki and call that "documentation"?

I have no idea how anybody ever released a game using Rain AI. The website is like something from an aborted start-up. If anybody can find the "world-class support" they promise on the website, I'll eat multiple hats.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9453 on: May 04, 2016, 09:55:59 am »

It's a completely free product. You get what you pay for, and nobody is paying these guys to write documentation.

flabort

  • Bay Watcher
  • Still a demilich, despite the 4e and 5e nerfs
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9454 on: May 04, 2016, 02:24:52 pm »

On a scale of 1 to 10, how hard is it to learn Lua?
Logged
The Cyan Menace

Went away for a while, came back, went away for a while, and back for now.

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9455 on: May 04, 2016, 02:45:55 pm »

On a scale of 1 to 10, how hard is it to learn Lua?


if you know another language, I'd say a 4 - the hardest part is that there are no conventional data structures but the dictionary which kind of work like your average map but not quite and only support certain keys.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9456 on: May 04, 2016, 03:46:27 pm »

Huh? Lua has a table, not a dictionary, and it's basically a combination between an array and a hash map which supports all keys (string, integers, tables and userdata are all valid keys).
« Last Edit: May 04, 2016, 03:49:42 pm by Putnam »
Logged

flabort

  • Bay Watcher
  • Still a demilich, despite the 4e and 5e nerfs
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9457 on: May 04, 2016, 05:11:48 pm »

Crosspost, as to the reason I want to learn Lua properly.
One reason I'm excited to see Sean doing some modding is because I've started some work on an ambitious project of my own. :P

So tell me, besides the fact that I haven't added image links or defined the items that these ores produce, is there anything blatantly wrong with this code?
Spoiler (click to show/hide)
Logged
The Cyan Menace

Went away for a while, came back, went away for a while, and back for now.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9458 on: May 04, 2016, 05:31:35 pm »

Code: [Select]
control = "adamite-ore"
sharpness = 1
richness_base = 500
stage_counts = {0}

if these lines don't have commas it'll error

Elephant Parade

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9459 on: May 04, 2016, 06:33:09 pm »

Still trying to learn to program. I've stuck with Python, but I'm not sure how good it is for making games; if it isn't great for that kind of thing, can someone recommend me a second language--one that is good for making games?

If it matters, I want to make a Mystery Dungeon-style game; something in the vein of Pokemon Mystery Dungeon, with sprites and randomly-generated floors and stuff.
Logged

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9460 on: May 04, 2016, 06:38:04 pm »

Python's ability to be good for any given thing is entirely dependent on what you're trying to do with it. There are some speed issues that make certain tasks more difficult, but as long as you use the tools you're playing with in Python right, it's going to be fine enough to make a turn based game like a mystery dungeon work.

The issue you're going to come across is in your distribution; Yes, you can make an .exe but I've found the process is a bit painful. I mean, it's the same way in so many other languages, and it's not as painful as trying to figure out C or C++, but there you go.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

flabort

  • Bay Watcher
  • Still a demilich, despite the 4e and 5e nerfs
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9461 on: May 04, 2016, 06:42:00 pm »

Code: [Select]
control = "adamite-ore"
sharpness = 1
richness_base = 500
stage_counts = {0}

if these lines don't have commas it'll error
Thanks.
Logged
The Cyan Menace

Went away for a while, came back, went away for a while, and back for now.

Spehss _

  • Bay Watcher
  • full of stars
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9462 on: May 05, 2016, 04:31:04 pm »

So I have a bug in this program for my college assignment. Program takes input/output from a binary file of struct data, and uses a menu interface to allow the user to add to the file, make changes to the file, or display either one specific struct or all of the structs in the file.

The bug consists of the program writing a duplicate struct of the last user input to the file. So if the user enters input for "Item 1" then goes to display all records in the file, "Item 1" is displayed twice. Additionally, my checkSize() function recognizes that this is actual data in the file, it's not just an issue with displaying data. Attempting to access this duplicate structure specifically with the function to display a specific struct results in displaying a bunch of garbage data. I think the duplicate is the result of the input/output buffer sending a bunch of garbage data when the file is closed and the buffer is flushed. But I can't be certain if that's what's causing it, and I can't find where the code is that's causing the bug.

Spoiler: c++ code (click to show/hide)
Logged
Steam ID: Spehss Cat
Turns out you can seriously not notice how deep into this shit you went until you get out.

breadman

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9463 on: May 05, 2016, 05:20:01 pm »

Still trying to learn to program. I've stuck with Python, but I'm not sure how good it is for making games;
PyWeek has many examples of simple games that were developed in Python within one week each.  It also has a list of tips and resources to help in such an endeavor.  One of the best ways to start may be with PyGame Zero.

But yes, distributing a Python game can still be harder than it really should be, particularly to Windows users.
Logged
Quote from: Kevin Wayne, in r.g.r.n
Is a "diety" the being pictured by one of those extremely skinny aboriginal statues?

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9464 on: May 05, 2016, 05:26:08 pm »

Distributing a Python program means (unless your audience can safely be assumed to have Python, ie Linux) distributing Python, and there aren't a lot of tools that make that very easy unless you were embedding Python in C or Java or something. And at that point, why not just write your game/app in those languages instead?

I most commonly see Python used as an embedded scripting language, kind of like Lua, so that people can add their own functionality to programs like Blender.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.
Pages: 1 ... 629 630 [631] 632 633 ... 796