Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 178 179 [180] 181 182 ... 796

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

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2685 on: July 25, 2012, 06:22:40 pm »

had dumb problem with fonts, but fixed it.
Issue was with advance width not being applied, but I found when I change my font to size 9.5 instead of 10 it applies the advance width, idk, it's dumb,
« Last Edit: July 25, 2012, 09:15:58 pm by Valid_Dark »
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2686 on: July 25, 2012, 08:13:33 pm »

I hate you python. My dying breath will be cursing your name.


Here's the bug that took me 4 days to figure out:
Code: [Select]
class DataItemVec(DataItem):
    def __init__(self, Dimensions = 1, Sizes = [], Values = {}):
        super(DataItemVec, self).__init__()
        self.dimensions = Dimensions
        self.sizes = {}
        self.values = Values
See that "Values = {}" at the top? Turns out that doesn't make a new dict every time the init function is called. So every, single, goddamn instance of this class was using the same exact dictionary for its values. I was wondering why the hell changing a value in one object would modify all others. And the answer is because python sucks.
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.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2687 on: July 25, 2012, 09:25:22 pm »

I hate you python. My dying breath will be cursing your name.


Here's the bug that took me 4 days to figure out:
Code: [Select]
class DataItemVec(DataItem):
    def __init__(self, Dimensions = 1, Sizes = [], Values = {}):
        super(DataItemVec, self).__init__()
        self.dimensions = Dimensions
        self.sizes = {}
        self.values = Values
See that "Values = {}" at the top? Turns out that doesn't make a new dict every time the init function is called. So every, single, goddamn instance of this class was using the same exact dictionary for its values. I was wondering why the hell changing a value in one object would modify all others. And the answer is because python sucks.

Insulting something because you don't understand it doesn't make anything better. Use dict() instead.

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2688 on: July 25, 2012, 09:29:45 pm »

IT MAKES ME FEEL BETTER  >:(

And according to the python docs that wouldn't work. To ensure a new dict each time, I have to either define it within the function or copy the Values dict before assigning it. I chose the former.
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.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2689 on: July 25, 2012, 09:50:49 pm »

If you want a powerful high-level language, try Python or Perl. You'll get good results really quickly. If you want to learn how to be a good programmer, try C++.
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2690 on: July 25, 2012, 09:54:09 pm »

Depends on what you want to do.  Program games?  C# maybe (with XNA), although if you don't have much/any programming experience I wouldn't recommend starting with C++.

If you just want to get your feet wet, starting with a higher level language is probably the best thing to do.  Python is probably a good choice, despite the problems just quoted.  :)  Ruby seems to be popular, although I know almost nothing about it.

If you want to learn a more fundamental language, C is kind of the standard.  It's not as complex as C++ so it's not as hard, but it's definitely more error prone than something like Python.
Logged
Through pain, I find wisdom.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2691 on: July 25, 2012, 09:56:43 pm »

I'd say that C is much more likely to break your brain than C++.
Logged

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2692 on: July 25, 2012, 10:05:03 pm »

Nothing builds character- like manual memory management.
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2693 on: July 25, 2012, 10:20:15 pm »

There is a reason why most people don't program in Assembly any more: You can only write down small thoughts.
Logged

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2694 on: July 25, 2012, 10:24:29 pm »

I started with c++, and it's still the only one I know, and I don't know very much of it.

I have another problem for any SDL wizards out there.
so my program is a SDL_NOFRAME program, is there any ways to make it dragable?
Because normally to drag a window you use the title bar at the top, but with a noframe program there is no title bar.  Whenever I launch it, it runs at a random spot on my screen and won't let me move it.
after googling for the last hour I found someone who had a answer on how to do it on linux, but I'm programming in windows and am aiming for it to be a windows program.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2695 on: July 25, 2012, 10:32:22 pm »

Hey, I've come across yet another problem that makes no sense at all. multimap::count is returning bogus values, and it's probably because of a custom class being used as the keys. I'm supposed to give the class an operator< function, but I'm not sure what to do with it. Everything I try either fails in most situations or produces a crash.

Spoiler: entire program (click to show/hide)
Logged

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2696 on: July 25, 2012, 10:41:24 pm »

I started with c++, and it's still the only one I know, and I don't know very much of it.

I have another problem for any SDL wizards out there.
so my program is a SDL_NOFRAME program, is there any ways to make it dragable?
Because normally to drag a window you use the title bar at the top, but with a noframe program there is no title bar.  Whenever I launch it, it runs at a random spot on my screen and won't let me move it.
after googling for the last hour I found someone who had a answer on how to do it on linux, but I'm programming in windows and am aiming for it to be a windows program.
After some digging:
http://wiki.libsdl.org/moin.cgi/SDL_SetWindowPosition?highlight=%28SDL%5C_Window%29
Does that work?

Spoiler (click to show/hide)
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2697 on: July 25, 2012, 10:42:44 pm »

Valid_Dark, if you are using SDL 2.0, you can use SDL_SetWindowPosition, but I think you are using an earlier version of SDL. You should have access to a function named SDL_GetWMInfo, which takes a pointer to a SDL_SysWMinfo struct as a parameter. The SDL_SysWMinfo struct has a member named 'window' which is the window handle which you need to pass to SetWindowPos.

dreadmullet, multimap::count returns the number of items having the given key, so why do you expect mmap.count(SimpleVec3(-1,-1,1)) to return 1 given that you add an item with the key SimpleVec3(0,55,-0.1)?
« Last Edit: July 25, 2012, 10:45:02 pm by RulerOfNothing »
Logged

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2698 on: July 25, 2012, 10:55:19 pm »

dreadmullet, multimap::count returns the number of items having the given key, so why do you expect mmap.count(SimpleVec3(-1,-1,1)) to return 1 given that you add an item with the key SimpleVec3(0,55,-0.1)?

I don't expect it to return 1, it DOES return 1, when it obviously shouldn't. My best assumption is that the operator < function that I gave SimpleVec3 is not correct, but I don't know what to do with it.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #2699 on: July 25, 2012, 10:56:50 pm »

Nothing builds character- like manual memory management.

Frak you.
Pages: 1 ... 178 179 [180] 181 182 ... 796