Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 41 42 [43] 44 45 ... 796

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

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #630 on: January 17, 2012, 08:51:31 am »

Ok, I'm done with libtcod. It has done well for itself, but I have outgrown it, and it can no longer suit my demands. I may still look to it for examples of how some of its algorithms work, but it is SDL for me...

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #631 on: January 17, 2012, 10:25:57 am »

Alright, I've just written a program that can generate islands, which produces results like this:
Spoiler (click to show/hide)
Thoughts?

I like it.  Looks like it was made by a volcano or something.
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #632 on: January 17, 2012, 10:46:39 am »

Alright, I've just written a program that can generate islands, which produces results like this:
Spoiler (click to show/hide)
Thoughts?


Looks like you added a displacement map to a circle. Am I correct?
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #633 on: January 17, 2012, 01:01:18 pm »

After work I am going to start on a java LWJGL 2d tile based gui interface. Normally I start my side projects from the back end, but I lose interest before I have anything I can demonstrate. Figured I would start from the other side this time, maybe throw out a crappy dungeon crawl adventure.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #634 on: January 17, 2012, 02:43:57 pm »

So I thought I'd be clever and badass and lazy and rewrite a lot of little pointers in my code, to capitalize on my newfound understanding of object references and public data, and get rid of some clunky ideas I had before.  Previously, the player and all mobs had their location relative to the tile-map stored as a two-element array (location[0] for X and location[1] for Y).  I originally did this so that methods could take in a position, do something with it, and then return a new position (since a method can only return one "thing", I made locations one "thing).  I went the whole hog and wanted to write a code where I don't make or use "Get" methods at all.

Well, I done fucked something up.  The screen-refreshing code is going crazy, mobs are invisible except when they walk diagonally, and I can't figure out where I went wrong.  And because I'm awesome, I didn't make any backups of the parts that are probably broken.  What a revolting predicament.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Vactor

  • Bay Watcher
  • ^^ DF 1.0 ^^
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #635 on: January 17, 2012, 02:50:37 pm »

Yeah, that'll happen, at some point you may want to set up an SVN repository so you can do a bit of revision control.

I've found that when you blow your code like that it helps to do something else while you give the code some deep thought.  I've usually had better luck realizing the root of problems when I'm not staring at the code itself, but thinking about its logic.  Take a walk and think of what would cause mobs to be invisible.
Logged
Wreck of Theseus: My 2D Roguelite Mech Platformer
http://www.bay12forums.com/smf/index.php?topic=141525.0

My AT-ST spore creature http://www.youtube.com/watch?v=0btwvL9CNlA

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #636 on: January 17, 2012, 02:51:30 pm »

Thanks for reminding me, I need to set up a SVN source control server when I get home. You may want to consider doing the same.

I got ninja'd
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #637 on: January 17, 2012, 02:53:17 pm »

Why use SVN when you can use Git?
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #638 on: January 17, 2012, 02:54:47 pm »

Why use SVN when you can use Git?

Because I know how to use SVN.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #639 on: January 17, 2012, 03:03:49 pm »

I've found that when you blow your code like that it helps to do something else while you give the code some deep thought.  I've usually had better luck realizing the root of problems when I'm not staring at the code itself, but thinking about its logic.  Take a walk and think of what would cause mobs to be invisible.

That's the thing though, the logic is all exactly the same.  I just cut out extraneous methods and calls, to condense the code with object pointers instead of Get-methods.  The problem has to an error in what's being sent where, I just can't figure out where it is, and there's not many places left to look.

It's pretty vexing.  Everything makes perfect sense to me, why can't the computer figure out what I want and work like it did thirty minutes ago?
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #640 on: January 17, 2012, 03:08:44 pm »

And today is a Very Special Episode, where Aqizzar learns the the value of version control. Heheh.

I predict the problem will be amazingly obvious AND in code you already looked at and decided wasn't the problem. This is my experience, and my intuition.
Logged

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #641 on: January 17, 2012, 03:21:47 pm »

And today is a Very Special Episode, where Aqizzar learns the the value of version control. Heheh.

I predict the problem will be amazingly obvious AND in code you already looked at and decided wasn't the problem. This is my experience, and my intuition.

You are correct.  I realized it was a display problem after some experimenting, and I learned a far more important lesson: to paraphrase a classic Toady fix, X and Y are not the same letter.  Ah, I love those moments.  Now to fix the mob-remover which has decided to stop working as well, and then I can move on to converting the ephemeral player into a defined object.

Speaking of which, a question for C# aficionados, can I set up a method to accept an object as a parameter, but in such a way that it accepts different objects?  I don't want the player and the mobs to be the same object (they'll have way too many differences), but I'd like to still use the same higher-class methods for both.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Red

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #642 on: January 17, 2012, 03:28:30 pm »

Speaking of which, a question for C# aficionados, can I set up a method to accept an object as a parameter, but in such a way that it accepts different objects?  I don't want the player and the mobs to be the same object (they'll have way too many differences), but I'd like to still use the same higher-class methods for both.

In C++ you can have both the player and the mobs objects have the same parent object. Then have the method accept an instance of the parent object as a parameter (I'm not sure if that would work in C#, however).
Logged

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #643 on: January 17, 2012, 03:30:27 pm »

That would be remarkably easy with duck typing - in C#, however, I think they'd either have to inherit from the same class and use that instead (which isn't a bad idea, really), or use an interface.
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #644 on: January 17, 2012, 03:30:35 pm »

Yes. There are multiple ways to do that.

1: pass in an object and cast it to whatever class you need, will need some type checking or try catch to when one of the casts fail. This is usually the wrong way to do it.

2: create an interface or superclass that both your character and mob inherit from. This interface/superclass exposes all the needed properties and methods needed by both types. Then you pass in an instance of either class to the method that accepts the interface/superclass. This is usually the right way.

3: There is another way to do it, but it is always the wrong way, and I won't tell you about it.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.
Pages: 1 ... 41 42 [43] 44 45 ... 796