Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 146 147 [148] 149 150 ... 796

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

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2205 on: April 17, 2012, 07:21:39 pm »

At naming variables sequentially : I don't know those things is the problem xD What's a vector? Is it those line things in math where planes fly and stuff? No? D:
I believe that lists in C++ are called vectors in the standard library.  It's just, like...well, it's a list of things.
A vector is not a list, it's a dynamic array. C++ does have the list class if you need lists, they're implemented as doubly-linked lists (each node knows it's predecessor and it's successor).

Anyway, an array is a block of memory that holds a sequence of data. For example, we have an array called A, containing, in sequence, the numbers 1 to 7. In memory, that looks like:
|1||2||3||4||5||6||7|
Now, we can access the contents of this array. Arrays in C++ are zero-indexed, so A[0] == 1, A[1] == 2 et cetera. We can also set them. After doing A[3] = 75;, the array looks like:
 |1||2||3||75||5||6||7|
Now, a vector is a dynamic array, which means it'll automatically handle resizing for you. If you use a normal array, you need to know the size beforehand and you have to do some memory twiddeling if you want to grow it, a vector does all of that for you.

Quote
Yeah, that's a job for a dictionary or two lists.
C++ calls dictionaries maps and they're the most elegant approach to this problem. using two lists is just ugly, and besides, hashing is O(1) with a very small prefactor, lookup in a list is O(n).
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2206 on: April 17, 2012, 07:41:54 pm »

Python is simultaneously awesome and headache-inducing. Programming what I thought would be a simple IRC bot in Python has turned out to be a major endeavor. THERE ARE SO MANY THINGS TO CONSIDER!

optimumtact

  • Bay Watcher
  • I even have sheep
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2207 on: April 18, 2012, 07:14:58 am »

Python is simultaneously awesome and headache-inducing. Programming what I thought would be a simple IRC bot in Python has turned out to be a major endeavor. THERE ARE SO MANY THINGS TO CONSIDER!

Heh, I have a partially implemented version in python 3.0, if you want I could upload my files to somewhere for you to look at them. It can connect and say stuff and has a partially implemented quote function. I decided to do a full rewrite asIt's written mostly in a functional style and I want to move to a object based multi-threaded(as much as python can do multi-threading anyway) module system.
Logged
alternately, I could just take some LSD or something...

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2208 on: April 18, 2012, 07:21:04 am »

I've got that much programmed, but it's the extra stuff that I'm trying to add in that's giving me a headache.

Aptus

  • Bay Watcher
  • Indeed ôo
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2209 on: April 18, 2012, 08:50:02 am »

---

I could probably write this in Verilog HDL in my sleep...I miss my FPGA...  Anyway, the reference manual for VHDL says that std_logic is defined as


Ahh finally got it to work, I realised I didn't need to use any case/ifs/when/while/whatever's at all to do it but could just write it as a basic logic expression.
Now the Adder/subber and the shifter is complete. Just the logic unit and this ALU will finally be complete.
Logged

Aptus

  • Bay Watcher
  • Indeed ôo
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2210 on: April 18, 2012, 08:55:29 am »

Hm. I'm thinking of getting into programming/coding but I have one question to ask: how much work do you think I should put in to get good at it?

I ask this because I am unfortunately afflicted with the oh-so-annoying trait of "drops something if it doesn't interest them in five seconds". Programming/Coding seems like it would take a LOT of time until you can actually make something interesting, and I don't want to drop it too soon.

Also, this probably isn't true at all, but I'm wondering if proficiency in natural languages helps when learning programming languages. I'm good when it comes to natural linguistics, but I wonder if that will transfer over to computer linguistics.


Being a good programmer takes quite a bit of practice, though it comes easier to some than to others as all things. I have just one tip for you, and it was a tip I needed to hear when I started out: Learning to become a programmer != learning a programming language. You are the artist and the language is but a tool.
Logged

optimumtact

  • Bay Watcher
  • I even have sheep
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2211 on: April 18, 2012, 10:56:47 am »

I think the important think is to remember to do examples. Sure book reading on it's own is ok. But it's really important that you write code and have some tangible result. Otherwise your interest will just drop off after a certain amount of time.
Logged
alternately, I could just take some LSD or something...

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2212 on: April 18, 2012, 01:36:06 pm »

Sure book reading on it's own is ok. But it's really important that you write code and have some tangible result.
it's really important that you write code and have some tangible result
tangible result

Results are the important thing.  You learn the most by finishing a project (and powering through it even if you decide you don't like its foundation, halfway through).
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2213 on: April 18, 2012, 01:39:30 pm »

Friend of mine who's an actual video game designer said this:


Get your game playable under a week. Doesn't matter what it looks like, doesn't matter how it plays, just get a GAME as soon as possible. All the foundations, asap.

There's no bigger killer of motivation than having a mountain of work ahead of you before being able to see a tangible result.
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2214 on: April 18, 2012, 01:57:08 pm »

Look up Derek Yu's articles on game design.  He's got undeniable indie street cred, whatever that means, and his advice is very relevant and well-written.
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2215 on: April 19, 2012, 12:08:08 am »

What was the problem?

The problem was that I was expecting the variable foundPlayer to be persistent when it clearly wasn't. When the nullptr becomes a pointer to the player, the else block cannot execute in the same call because it's already gone into the if(nullptr) block. On the next call, a new foundPlayer variable would be initialised with a nullptr, and the problem would start anew.

The solution was to place it in the class itself for persistency (duh).
Logged

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2216 on: April 19, 2012, 12:17:46 am »

Oy, that feels familiar...  Null is such a wonderful thing, but it causes so many problems at the same time if not used just right.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2217 on: April 19, 2012, 07:23:41 am »

Stargrasper = null;

Simmura McCrea

  • Bay Watcher
    • View Profile
    • My Steam profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2218 on: April 19, 2012, 08:33:16 am »

Anyone know how to pass an array of pointers to objects by reference in C++?
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2219 on: April 19, 2012, 08:34:39 am »

That depends. Do you want to mutate the array itself or the pointers that comprise the array?
Logged
Pages: 1 ... 146 147 [148] 149 150 ... 796