What are you working on? V4 (HTML ISN'T PROGRAMMING)
2,003 replies, posted
[QUOTE=Kylegar;18186962]it works natively. If statements check if the value passed is not 0. The only time a object would be 0 is if it's null (#define NULL (void *)0 ), so, if the class is NULL, then the condition would be false, and the if statement would not be triggered.[/QUOTE]
actually sir, NULL in C++ is defined as just plain 0. C is the (void *)0 version.
[QUOTE=Kylegar;18186962]it works natively. If statements check if the value passed is not 0. The only time a object would be 0 is if it's null (#define NULL (void *)0 ), so, if the class is NULL, then the condition would be false, and the if statement would not be triggered.[/QUOTE]
No, you are thinking of pointers to objects, and he is thinking of operator bool (but I seeeeem to remember operator bool getting a bit hacky at some point).
[B]Edit:[/B]
Found it, this is where it gets hacky:
[url]http://www.artima.com/cppsource/safebool.html[/url]
You're better off just creating an isValid() member function really.
[QUOTE=r4nk_;18186554]Riighhht, so then you don't get any experience in the most popular IDEs and when it comes time to get a job you are at a huge disadvantage. I know not all companies use IDEs for the reasons you have specified, but a lot do.[/QUOTE]
I just migrated my project into C::B at the behest of manageability, and these are my problems with it. I've never used IDEs before, but there was nothing difficult [I]at all[/I] with using it. In fact, I daresay it holds your hand too much, which is why I'm bitching about incompatibilities and not being able to port your project to autotools. And yes, the code profiler was another beef, as it didn't exist, and I can't find the code profiler plugin (although it is rumored to exist [I]somewhere.[/I])
In fact, I consciously try to run software that wasn't designed with the assumption that the user is a retard. (which is why I can't stand using Windows)
On a side note we've gotten dependency tracking working, although is appears to have broken file checking :S. We're gearing up for a refactor though, as to get it working we've been mostly performing quick hacks.
[QUOTE=Chandler;18187057]actually sir, NULL in C++ is defined as just plain 0. C is the (void *)0 version.[/QUOTE]
Sue me :P
[QUOTE=r4nk_;18187082]No, you are thinking of pointers to objects, and he is thinking of operator bool (but I seeeeem to remember operator bool getting a bit hacky at some point).
[B]Edit:[/B]
Found it, this is where it gets hacky:
[url]http://www.artima.com/cppsource/safebool.html[/url]
You're better off just creating an isValid() member function really.[/QUOTE]
Oh, you are right, I misread his code.
[QUOTE=r4nk_;18185909]cuz all tha hard cor -._.-~*~HaCkErZ~*-._.- h8 tha IDEz[/QUOTE]
ya mayne emacs n vi ftw i dun need da IDE to heLp me with producTifity ```..Fuck DaTTT im Too Pro 4 Dattt~`` linux 4 lyfeeee
[b]EDIT: I fixed it myself. Didn't think of actually letting each thread get some CPU time. Added a simple time.sleep(0.01) to the end of each run() function, and now it works.[/b]
Gah. Can anyone explain to me how to use threads properly in Python?
I've got two Threading classes, 'ThreadedRender' and 'ThreadedLogic'.
ThreadedRender handles all the Pygame drawing stuff for my script - blitting sprites to the screen etc.
ThreadedLogic handles the rest - events processing (mouse+key presses), creation of objects, object movement.
Both run as non-escaping loops (while ALIVE == True: do everything), but they don't seem to be able to run at the same time, kinda' defeating the point of having two threads.
I can run the script fine if I just call their run() functions in a while loop - but that's not threaded, then. I want the Logic & Drawing code to run simultaneously. But yet it seems if I call
ThreadedRender.start()
and
ThreadedLogic.start()
only ThreadedRender will run its while loop.
How do I get them to actually run fuckin' simultaneously, like two different threads should? :argh:
Related code (rest of script is... well, related, but not causing the problem, so I omitted it, there's quite a lot):
[code]class ThreadedDisplay(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
pygame.display.set_caption('Yay balls!')
self.screen = pygame.display.set_mode(res, pygame.DOUBLEBUF|pygame.HWSURFACE)
self.pixels = pygame.PixelArray(self.screen)
def run(self):
global ALIVE
while ALIVE == 1:
self.screen.fill(0x000000)
map(Ball.draw,balls)
pygame.display.update()
class ThreadedLogic(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.time = clock()
self.lastTime = clock()
def run(self):
global ALIVE
while ALIVE == 1:
if pygame.key.get_pressed()[pygame.K_ESCAPE] == 1:
ALIVE = 0
exit()
if pygame.key.get_pressed()[pygame.K_SPACE] == 1 and self.lastTime+.5 < clock():
self.lastTime = clock()
new_ball()
if pygame.mouse.get_pressed()[0] == 1 and self.lastTime+.1 < clock():
self.lastTime = clock()
#print pygame.mouse.get_pos()
new_ball(pos=[pygame.mouse.get_pos()[0],pygame.mouse.get_pos()[1]])
if pygame.mouse.get_pressed()[1] == 1 and self.lastTime+.2 < clock():
self.lastTime = clock()
new_ball(pos=[pygame.mouse.get_pos()[0],pygame.mouse.get_pos()[1]],color=0xFFFFFF,type='GravityBall')
#pygame.display.set_caption('Balls: '+str(len(balls)))
map(Ball.move,balls)
pygame.event.get()
self.time = clock()-self.time
if __name__=="__main__":
ThreadedDisplay().start()
ThreadedLogic().start()
while 1:
pygame.event.get() # even if neither thread does anything this'll stop the program from hanging[/code]
[QUOTE=Cathbadh;18187258]And yes, the code profiler was another beef, as it didn't exist, and I can't find the code profiler plugin (although it is rumored to exist [I]somewhere.[/I])[/QUOTE]
If you're such an experienced do-it-yourself-er you'd know that you simply need to compile with proper profiling options enabled and then run an external profiler, such as CodeAnalyst.
[QUOTE=Cathbadh;18187258]I just migrated my project into C::B at the behest of manageability, and these are my problems with it. I've never used IDEs before, but there was nothing difficult [I]at all[/I] with using it. In fact, I daresay it holds your hand too much, which is why I'm bitching about incompatibilities and not being able to port your project to autotools. And yes, the code profiler was another beef, as it didn't exist, and I can't find the code profiler plugin (although it is rumored to exist [I]somewhere.[/I])
In fact, I consciously try to run software that wasn't designed with the assumption that the user is a retard. (which is why I can't stand using Windows)[/QUOTE]
Yeah GUIs are so condescending.
[QUOTE=TehDoomCat;18187927][b]EDIT: I fixed it myself. Didn't think of actually letting each thread get some CPU time. Added a simple time.sleep(0.01) to the end of each run() function, and now it works.[/b]
Gah. Can anyone explain to me how to use threads properly in Python?
I've got two Threading classes, 'ThreadedRender' and 'ThreadedLogic'.
ThreadedRender handles all the Pygame drawing stuff for my script - blitting sprites to the screen etc.
ThreadedLogic handles the rest - events processing (mouse+key presses), creation of objects, object movement.
Both run as non-escaping loops (while ALIVE == True: do everything), but they don't seem to be able to run at the same time, kinda' defeating the point of having two threads.
I can run the script fine if I just call their run() functions in a while loop - but that's not threaded, then. I want the Logic & Drawing code to run simultaneously. But yet it seems if I call
ThreadedRender.start()
and
ThreadedLogic.start()
only ThreadedRender will run its while loop.
How do I get them to actually run fuckin' simultaneously, like two different threads should? :argh:
Related code (rest of script is... well, related, but not causing the problem, so I omitted it, there's quite a lot):
[code]class ThreadedDisplay(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
pygame.display.set_caption('Yay balls!')
self.screen = pygame.display.set_mode(res, pygame.DOUBLEBUF|pygame.HWSURFACE)
self.pixels = pygame.PixelArray(self.screen)
def run(self):
global ALIVE
while ALIVE == 1:
self.screen.fill(0x000000)
map(Ball.draw,balls)
pygame.display.update()
class ThreadedLogic(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.time = clock()
self.lastTime = clock()
def run(self):
global ALIVE
while ALIVE == 1:
if pygame.key.get_pressed()[pygame.K_ESCAPE] == 1:
ALIVE = 0
exit()
if pygame.key.get_pressed()[pygame.K_SPACE] == 1 and self.lastTime+.5 < clock():
self.lastTime = clock()
new_ball()
if pygame.mouse.get_pressed()[0] == 1 and self.lastTime+.1 < clock():
self.lastTime = clock()
#print pygame.mouse.get_pos()
new_ball(pos=[pygame.mouse.get_pos()[0],pygame.mouse.get_pos()[1]])
if pygame.mouse.get_pressed()[1] == 1 and self.lastTime+.2 < clock():
self.lastTime = clock()
new_ball(pos=[pygame.mouse.get_pos()[0],pygame.mouse.get_pos()[1]],color=0xFFFFFF,type='GravityBall')
#pygame.display.set_caption('Balls: '+str(len(balls)))
map(Ball.move,balls)
pygame.event.get()
self.time = clock()-self.time
if __name__=="__main__":
ThreadedDisplay().start()
ThreadedLogic().start()
while 1:
pygame.event.get() # even if neither thread does anything this'll stop the program from hanging[/code][/QUOTE]
Python doesn't do threading like other languages.
If you don't want to do the time.sleep() trick Instead, do something like this
lock = threading.Lock()
lock.aquire()
~WHILE LOOP~
lock.release()
(note not EXACTLY like that)
Or you could switch from threading.Thread to Queue.
Since that's effectively how Python does it's threading anyways :/
[QUOTE=nullsquared;18188392]If you're such an experienced do-it-yourself-er you'd know that you simply need to compile with proper profiling options enabled and then run an external profiler, such as CodeAnalyst.[/QUOTE]
As it stands now, I just use gprof in the terminal. But my abilities aren't the reason that I'm bitching. I'm bitching because if you don't natively support the functionality in your IDE, other programmer less accustomed to getting their hands dirty with this stuff simply [I]won't[/I] run their code through valgrind or a profiler. That's bad.
This is why people still write Visual Basic.
[editline]03:52PM[/editline]
[QUOTE=Ortzinator;18188474]Yeah GUIs are so condescending.[/QUOTE]
It's not GUI's that are condescending, it's the attitude of the developers who just [I]know[/I] that their users are going to try something stupid with their software, [U]and they are completely correct in this respect.[/U]
If you have a little brother, perhaps you remember playing video games with him at a young age, but instead of letting him play, you just gave him a controller and play the game yourself while he mashes the buttons and believes that he is the one controlling mario. It's uncanny how [I]effective[/I] this is. That's the experience of using such software.
[QUOTE=r4nk_;18187082]No, you are thinking of pointers to objects, and he is thinking of operator bool (but I seeeeem to remember operator bool getting a bit hacky at some point).
[B]Edit:[/B]
Found it, this is where it gets hacky:
[url]http://www.artima.com/cppsource/safebool.html[/url]
You're better off just creating an isValid() member function really.[/QUOTE]
Wow that was a bit overkill.
Overloading the type conversion is fine. Even with side effects I don't care about.
Would never need to assign my class to a bool or int anyway.
[cpp]
class Class
{
public:
operator bool() { return true; }
}
[/cpp]
I'm currently working on a space thingie, i'l post a vid when it has some more feature's.
1 question : I am making a system that opens a window when you hold the right mouse and does something else (move) when you click the right mouse. This is called every think frame of my input manager :
[cpp]
mouse_right = Input.IsMouseButtonDown(sf::Mouse::Right);
if (mouse_right == true)
{
hold_right += Render.GetFrameTime();
}
if (mouse_right == false && hold_right > 0)
{
if (hold_right >= 0.5)
{
hold_right = 0;
std::cout << "Window" << std::endl;
} else {
hold_right = 0;
std::cout << "Click" << std::endl;
}
}
[/cpp]
Is this a good way to check it (performance wise ?)
[QUOTE=Cathbadh;18188815]As it stands now, I just use gprof in the terminal. But my abilities aren't the reason that I'm bitching. I'm bitching because if you don't natively support the functionality in your IDE, other programmer less accustomed to getting their hands dirty with this stuff simply [I]won't[/I] run their code through valgrind or a profiler. That's bad.
This is why people still write Visual Basic.
[editline]03:52PM[/editline]
It's not GUI's that are condescending, it's the attitude of the developers who just [I]know[/I] that their users are going to try something stupid with their software, [U]and they are completely correct in this respect.[/U]
If you have a little brother, perhaps you remember playing video games with him at a young age, but instead of letting him play, you just gave him a controller and play the game yourself while he mashes the buttons and believes that he is the one controlling mario. It's uncanny how [I]effective[/I] this is. That's the experience of using such software.[/QUOTE]
Do you have an example?
[QUOTE=Cathbadh;18188815]Mashes the buttons and believes that he is the one controlling mario. It's uncanny how [I]effective[/I] this is. That's the experience of using such software.[/QUOTE]
No it's not...?
I'd rather have a fool-proof GUI than a GUI that offered various buttons that are destructive and tell me "LOL oh well YOU pressed me." Even programmers make mistakes. I take it you've never written anything large enough where making a small mistake that destroys everything is an issue.
[QUOTE=nullsquared;18189898]No it's not...?
I'd rather have a fool-proof GUI than a GUI that offered various buttons that are destructive and tell me "LOL oh well YOU pressed me." Even programmers make mistakes. I take it you've never written anything large enough where making a small mistake that destroys everything is an issue.[/QUOTE]
The scalability issue is exactly why I'm migrating to using an IDE for this project. I will admit that using an IDE makes large projects more manageable, but I can still make complaints where I believe IDE's pamper you to the point of uselessness. When was the last time you made a makefile? Ever set the -funsafe-math-operations compiler flag because it's fun and safe? IDE's don't teach the programmer about this stuff, and actively discourage the programmer from doing so. Sure, you can ride your bike with the training wheels on it forever and get everywhere you want to go on into adulthood, but why would you want to go on everywhere looking like a tard?
[url]http://github.com/compwhizii/CBot[/url]
Rewriting my IRC Bot.
[QUOTE=Cathbadh;18190879]The scalability issue is exactly why I'm migrating to using an IDE for this project. I will admit that using an IDE makes large projects more manageable, but I can still make complaints where I believe IDE's pamper you to the point of uselessness. When was the last time you made a makefile? Ever set the -funsafe-math-operations compiler flag because it's fun and safe? IDE's don't teach the programmer about this stuff, and actively discourage the programmer from doing so. Sure, you can ride your bike with the training wheels on it forever and get everywhere you want to go on into adulthood, but why would you want to go on everywhere looking like a tard?[/QUOTE]
Yeah, because everyone is gonna point and laugh at you! I'd rather wear cool looking pants that have no pockets, instead of the practical ones!
Making makefiles is a waste of time. Doing programming without an IDE is also a waste of time. We're in the 21st century now. Why don't you start programming in assembler too? Because C++ pampers you too much with all this OOP shit!
[QUOTE=Spoco;18192868]Yeah, because everyone is gonna point and laugh at you! I'd rather wear cool looking pants that have no pockets, instead of the practical ones!
Making makefiles is a waste of time. Doing programming without an IDE is also a waste of time. We're in the 21st century now. Why don't you start programming in assembler too? Because C++ pampers you too much with all this OOP shit![/QUOTE]
I anticipated this response. There's nothing practical or impractical about any of this. It's just being lazy.
And I'm not sure where you're coming from with not wanting to write makefiles. They are a level of abstraction that's supposed to make code compilation easy! Isn't that exactly what you are claiming to support? What are you going to do then when someone hands you a bunch of source files and headers for a huge project and ask you to port it and compile to a certain target platform?
And yeah, you're right about C++ being bogus. Not because it is too easy, but it is too hacky. Then again, I'm the TA who smacks his students whom write inline assembly routines. Link it in, bozo, don't put it in your C source.
No, all this stuff is not a waste of time, and I blame IDE's for making you think that you don't need to learn this shit. That's exactly what I'm saying.
can we just start posting programming stuff again?
[QUOTE=NovembrDobby;18193897]can we just start posting programming stuff again?[/QUOTE]
As long as both sides feel that the other is stupid and that they are capable of defending their position, then probably not. No amount of box ratings will convince me to change positions, but reasoned argument [I]might just.[/I]
[QUOTE=Spoco;18192868]Yeah, because everyone is gonna point and laugh at you! I'd rather wear cool looking pants that have no pockets, instead of the practical ones!
Making makefiles is a waste of time. Doing programming without an IDE is also a waste of time. We're in the 21st century now. Why don't you start programming in assembler too? Because C++ pampers you too much with all this OOP shit![/QUOTE]
I like how you compare programming without an IDE to programming in assembler - It's not the same thing at all. Not using a one-size-fits-all IDE means you get to pick and choose your own tools, and get to really know them and use them well, instead of pressing the cute little GUI buttons that do things for you. It's not even a waste of time - Some people are a lot faster without IDEs (unless you consider VIM + Other programming tools an IDE, but I'd say the word Integrated makes it not one) than with one.
So basically you're suggesting you pick the tools that make you work easier and faster. For Cath, that happens to be makefiles and a solid text editor, along with a compiler, debugger, and profilers. Which is exactly what he was using until now.
Why is everyone bitching about not using an IDE?
Just because we're living in the "21st century" doesn't mean that an IDE is the only way to program. Hell, the 21st century view of program creation is based around the concept of not making the user think.
And not having experience in a specific IDE is a pretty poor basis for being hired, if a company dropped me because I didn't use Visual-AutoMagician-200! I'd say that's a pretty poor company, since any programmer worth his salt can adapt his knowledge to his tools.
[QUOTE=Cathbadh;18188815]
It's not GUI's that are condescending, it's the attitude of the developers who just [I]know[/I] that their users are going to try something stupid with their software, [U]and they are completely correct in this respect.[/U]
[/QUOTE]
This is the second time you've taken shots at people who don't know how to use a computer. I'll bet you there are some badass oldschool badasses and shit out there that can whoop your ass academically, but they couldn't do much of anything with a computer.
*Prays for a ban wave to sweep this thread*
Anyways, getting my packet logger ready for release so I am learning to use RSA(to prevent packet spoofing). That is about all I can do to prevent cracking :P. .NET Reactor wont support control flow obfuscation for mixed assemblies for a few months. Although I do have all my authentication code in pure unmanaged :P.
[QUOTE=windwakr;18194780]Actually, the assembler I use has a very nice IDE.
Here's a screenshot I found of it:
[img]http://diamond.kolibrios.org/hll/hll_fasm2.gif[/img]
You bring up a good point. [b]Why[/b] don't you all start programming in assembly? It's not hard, your programs will almost always be 10000000000x smaller than C/C++ coded programs, you'll get laid, etc.[/QUOTE]
i seriously hope you're being sarcastic/trolling.
[QUOTE=Cathbadh;18193212]I anticipated this response. There's nothing practical or impractical about any of this. It's just being lazy.
And I'm not sure where you're coming from with not wanting to write makefiles. They are a level of abstraction that's supposed to make code compilation easy! Isn't that exactly what you are claiming to support? What are you going to do then when someone hands you a bunch of source files and headers for a huge project and ask you to port it and compile to a certain target platform?
And yeah, you're right about C++ being bogus. Not because it is too easy, but it is too hacky. Then again, I'm the TA who smacks his students whom write inline assembly routines. Link it in, bozo, don't put it in your C source.
No, all this stuff is not a waste of time, and I blame IDE's for making you think that you don't need to learn this shit. That's exactly what I'm saying.[/QUOTE]
You keep talking about "learning" as if everyone who uses an IDE is a noob.
[QUOTE=windwakr;18194780]Actually, the assembler I use has a very nice IDE.
Here's a screenshot I found of it:
[img]http://diamond.kolibrios.org/hll/hll_fasm2.gif[/img]
You bring up a good point. [b]Why[/b] don't you all start programming in assembly? It's not hard, your programs will almost always be 10000000000x smaller than C/C++ coded programs, you'll get laid, etc.
[editline]...[/editline]
Why the funnies? I am serious, except for the getting laid part.[/QUOTE]
Why the funnies? because what you said was so idiotic that it was funny.
[QUOTE=Jawalt;18195040]This is the second time you've taken shots at people who don't know how to use a computer. I'll bet you there are some badass oldschool badasses and shit out there that can whoop your ass academically, but they couldn't do much of anything with a computer.[/QUOTE]
You and I are referencing two different sets of people. I mean to say that [I]just about every user who uses your software is going to do something stupid with it.[/I] Doesn't matter how computer literate they are, if it is someone other than the person who wrote the software, then they are probably trying to use that software in some brainless fashion. Myself included. I just want my software to tell me when I take a shit on the kitchen floor and rub my nose in it instead of silently cleaning it up. (The windows analogy would be to spray something nice-smelling in the air, and put another layer of linoleum on top of the shit)
How else are you gonna learn anything?
[editline]12:09AM[/editline]
[QUOTE=Ortzinator;18196363]You keep talking about "learning" as if everyone who uses an IDE is a noob.[/QUOTE]
I don't know anyone who can truthfully say that they've finished learning.
Sorry, you need to Log In to post a reply to this thread.