Bay 12 Games Forum

Please login or register.

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

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

Aqizzar

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

Reflection sounds like something I'll have to read up on.  If my current modus operandi is any indication, I'll need more dangerously necromantic coding practices against which to bargain my soul.

Three hours of work later, and I have successfully converted my Player to an object, referenced in all the places it needs to be, and managed to change over all my old crappy static array nonsense to the new pointers without a single error.  Eat your heart out, sensible version-protection practices.  Boy, you sure do spend a lot of time in programming correcting your own old ideas.

The only method left that relies on my location-as-array scheme is a random placement function, and then because I haven't gotten around to figuring out how Superclasses work, so I'm just brute-forcing the function.  At least it still works.
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.

Nadaka

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

I knew even uttering that word was saying too much.

Tis' dark and blasphemous speech.
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.

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #662 on: January 17, 2012, 05:32:50 pm »

This is what reflection can do for you.

Code: [Select]
        public static void PrintAllNClasses(string nameSpace)
        {
            // this is me LITERALLY GRABBING THE ENTIRE PROGRAM BY THE POINTERS
            Assembly asm = Assembly.GetExecutingAssembly();
            // Now I grab every class type in the entire program and cycle through them all
            foreach (Type type in asm.GetTypes())
            {
                // I make sure that they are within the namespace I select, and then check to see what letter it starts with (after a hack job of making sure it's case insensitive
                if (type.Namespace == nameSpace && type.Name.ToUpper().StartsWith("N"))
                    Console.WriteLine(type.Name);
            }
            // BANG done
        }

Spoiler: result (click to show/hide)
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 /

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #663 on: January 17, 2012, 05:38:20 pm »

This is what reflection can do for you.

Code: [Select]
        public static void PrintAllNClasses(string nameSpace)
        {
            // this is me LITERALLY GRABBING THE ENTIRE PROGRAM BY THE POINTERS
            Assembly asm = Assembly.GetExecutingAssembly();
            // Now I grab every class type in the entire program and cycle through them all
            foreach (Type type in asm.GetTypes())
            {
                // I make sure that they are within the namespace I select, and then check to see what letter it starts with (after a hack job of making sure it's case insensitive
                if (type.Namespace == nameSpace && type.Name.ToUpper().StartsWith("N"))
                    Console.WriteLine(type.Name);
            }
            // BANG done
        }

Spoiler: result (click to show/hide)

I actually find this incredibly useful in ruby when I don't have documentation on a class and am trying to figure out what I can do with it.

Spoiler (click to show/hide)
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #664 on: January 17, 2012, 06:35:05 pm »

Well, today was my first day of Java and C. Like I expected, we're starting with the super-basics (like, what hardware is). In the Java class, I managed to bork a "Hello World" script. Which I copied from the projector that the teacher had up. Am I doomed?
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #665 on: January 17, 2012, 06:37:19 pm »

Well, today was my first day of Java and C. Like I expected, we're starting with the super-basics (like, what hardware is). In the Java class, I managed to bork a "Hello World" script. Which I copied from the projector that the teacher had up. Am I doomed?

Nah, that is normal for the first day.  :)  In a lot of ways the biggest struggle for most people when they are starting to learn programming isn't so much the concepts but the actual syntax.  Its a tricky thing. 
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #666 on: January 17, 2012, 06:44:54 pm »

That's the thing though, I'm not "just starting" to learn to program, I did it years ago. I flew half-way across the country to be in a competition (didn't do so well, but I was the only person from my state to go). This is more of a re-learning experience, and I failed the simplest program known to man.

Not just failed, but I got 7 errors in as many lines of code. Srsly?
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #667 on: January 17, 2012, 06:46:15 pm »

For me it was the software and hardware. I figured out how to program with logic gates before I ever got a compiler to work, hah.
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #668 on: January 17, 2012, 06:46:32 pm »

Hehe.  I wouldn't worry about it as long as you can figure out what you did wrong.
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

GlyphGryph

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

Also, that is /seriously/ all reflection is? I thought it was going to be some sort of dark magic, not something I used all the time. And I didn't even know what it was. Hah.
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #670 on: January 17, 2012, 06:48:47 pm »

Not at the moment, I think I was in shock (and I hadn't eaten anything yet). Here's hoping I'll have some progress in the next couple of weeks.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #671 on: January 17, 2012, 07:05:05 pm »

Eh, I tend to not use reflection that much, it becomes a bit of a broad sword when you should be using a scalpel.
Sure, you can do some cool shit, but it makes your program so damn fragile, and a lot of the time when you are making a real program, there is a better way.

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #672 on: January 17, 2012, 07:11:56 pm »

Yeah, one of my big realizations when I first "got" reflection was "UNLIMITED POWAAAARRRR ... but when will I ever encounter something I need to use it for? :("

A search that continues to this day aside from the few scattered places where it can be useful to have.
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 /

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #673 on: January 17, 2012, 07:15:11 pm »

I think I mostly use it for bug testing and framework level stuff - I can't recall the last time I used it with business logic. Ah... wait... I think I use it sometimes to create dynamically generated methods. But I guess that's back to framework level stuff.
Logged

Aqizzar

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

I've been liking how I've got my AI organized though.  I've got a set of AI objects like:

IdleAI, WanderAI, PatrolAI, DigAI, RunAwayAI, SeeAndAttackAI.

And each monster definition includes a list of these AI objects in a particular order.

Whenever the AI is queried for an action, it starts at the top of the list and if an AI doesn't return an action, it goes and checks the next one until it finds one that feels like doing something.

Hey Levi, if you don't mind, I'd be curious to see an example of how you have this organized.

I've built a couple functions for my mobs, so they can randomly walk around, and if they know they're next to a target (only valid target is the player right now) they "attack" (write a message right now - I'm still brainstorming for message-buffering).  I know I need to have this better arranged though, so it doesn't all just pile up in the MobObject class and I can make a clean AI system from the start.

I'm also realizing how close I am to making something I can honestly call a roguelike.  If I can "attack" the mobs and they can "attack" me then all I need now is numbers and math and then stuff will happen.  Throw in a button to make a screen to see your numbers, and it will fit the most basic possible criteria of a game.
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.
Pages: 1 ... 43 44 [45] 46 47 ... 796