Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 263 264 [265] 266 267 ... 796

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

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3960 on: February 19, 2013, 06:29:48 am »

Every time I look at python declarations, I cringe because it looks like the reserved system functions in C++ xD
Things that look like _pblockid(), or _global_, or such, and usually have inline C code. Scary-looking, terse, incomprehensible C code.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3961 on: February 19, 2013, 12:09:32 pm »

I bwhut.

SADWDsfdsfds

Freaking compiler. I just spent an hour trying to figure out why the hell having an std::string, constructing a class or doing pretty much anything useful was causing memory errors. Apparently the compiler/debugger couldn't notice the fact that half the program was compiled earlier with another compiler, and the other half with another(updated the compiler, least thats what I assume happened). Just needed to rebuild the darn thing.
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3962 on: February 19, 2013, 01:11:26 pm »

Anyway, how do you create new classes inside of a class? I tried to do it like I do it in a function (which works) but I get this:
Code: [Select]
File "C:\<~~>\person.py", line 13, in __init__
    self.age = time.Time(1, 20)
AttributeError: 'module' object has no attribute 'Time'
I can move this to the function which creates the person class, but I'd prefer to do it in __init__.

More information is needed. How is time imported?

Also, function which creates the person class? That's __init__(). You're not declaring a function named Time(), are you?
Logged

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3963 on: February 19, 2013, 01:28:11 pm »

Time is a class, located in time.py

time.py is imported in all modules, as I thought that might fix the problem, but it didn't :P. I import before anything else in modules. The person class is created in worldgen.py.

Some relevant parts:
Code: [Select]
# person.py
# Contains the Person class

import time

class Person:
    def __init__(self, gamedefault):

        self.age = time.Time(1, 20)
Code: [Select]
# time.py
# Contains the Time class

import random
import time

class Time:
    def __init__(self, monthInit=1, yearInit=1):
        self.month = monthInit
        self.year = yearInit
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3964 on: February 19, 2013, 01:45:31 pm »

I just recreated your environment to the best of my ability and I'm not getting any errors. Hmm...
Logged

Berserker

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3965 on: February 19, 2013, 01:49:06 pm »

Python already has a module called time, maybe person.py is using that instead of the time.py you created?
Logged

Antur

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3966 on: February 19, 2013, 01:49:57 pm »

Depending where the time.py is located in your file tree you could be importing time.py from standard library there. (python imports are sometimes pretty crazy)

(Ninja'ed)
Logged

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3967 on: February 19, 2013, 01:51:09 pm »

Python already has a module called time, maybe person.py is using that instead of the time.py you created?

Changed everything to timeMod and that fixed it! Thanks :D
« Last Edit: February 19, 2013, 01:53:27 pm by Dutchling »
Logged

SethCreiyd

  • Bay Watcher
  • [VESPERTINE]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3968 on: February 19, 2013, 01:52:11 pm »

Built-in modules like time have priority with import statements unless you perform magic.  Ninjas.
Logged

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3969 on: February 23, 2013, 01:10:36 pm »

anyone know of a precooked example of a multiplayer 2d physic example like this one
https://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs

but in java because I am lazy and don't wan't to have anything to do with js?
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3970 on: February 24, 2013, 11:40:12 pm »

Speaking of games and Java, anybody know a good package to make games with Java? Specifically for 2d graphics, also sound and input bundled is nice.
I don't think java.swing is what one might call ideal...

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3971 on: February 24, 2013, 11:46:01 pm »

Speaking of games and Java, anybody know a good package to make games with Java? Specifically for 2d graphics, also sound and input bundled is nice.
I don't think java.swing is what one might call ideal...
I can only recommend LWJGL (LightWeight Java Game Library). It has OpenGL.
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3972 on: February 24, 2013, 11:46:06 pm »

Speaking of games and Java, anybody know a good package to make games with Java? Specifically for 2d graphics, also sound and input bundled is nice.
I don't think java.swing is what one might call ideal...

Slick2D? Maybe here...

The main site (slick2d.org) seems to be down, so I'm not sure if I should even be recommending this anymore.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3973 on: February 24, 2013, 11:50:03 pm »

I can only recommend LWJGL (LightWeight Java Game Library). It has OpenGL.
I have heard some good things, and some bad. Mainly that it is pretty fast and thin though, so might be worth dealing with what will no doubt amount to crappy documentation. If I don't get any other contenders, then we have a winner by default.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3974 on: February 25, 2013, 12:08:38 am »

I can only recommend LWJGL (LightWeight Java Game Library). It has OpenGL.
I have heard some good things, and some bad. Mainly that it is pretty fast and thin though, so might be worth dealing with what will no doubt amount to crappy documentation. If I don't get any other contenders, then we have a winner by default.
Well, I found it extremely easy to use. I need only ~10 calls to the library in my projects (not counting OpenGL calls), and if you need some OpenGL documentation, I can documentation for you. Want an example game source?
Logged
Pages: 1 ... 263 264 [265] 266 267 ... 796