• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=cody8295;39522540]Anybody know why this isn't working? I'm just trying to draw a rectangle D: [IMG]http://i.imgur.com/y10hZcZ.png[/IMG][/QUOTE] glRect doesn't work when inbetween glBegin/glEnd.
[QUOTE=Liquid Helium;39523239]glRect doesn't work when inbetween glBegin/glEnd.[/QUOTE] Even when I move the function before/after the begin/end calls, it produces the same result..
[QUOTE=ArgvCompany;39519051]Not sure what you refer to with "very present visual effect menu".[/QUOTE] A program that would essentially run in a full window, and basically act like a mini operating system
[QUOTE=Meatpuppet;39522549]I don't see what you mean. Here's my project on git: [url]https://github.com/Tetramputechture/Yttra[/url][/QUOTE] Your main calls Game::Start which calls Game::GameLoop which calls Game::showMMenu which calls Menu::showMMenu which calls Text::create which [b]a ha![/b] finally calls Window::draw. I need to look at four different source files and five function calls before I know where the draw calls are occurring. There's technically nothing wrong with structuring things like that, but take a look at the end of the game loop in my Bananagrams clone: [cpp] window.clear(background); grid.draw_on(window); window.draw(cursor); window.draw(mcursor); display.draw(); messages.draw_on(window); window.display(); [/cpp] Even without seeing the rest of my code, it's pretty clear how I'm preparing the screen for each frame.
[QUOTE=SIRIUS;39524193]A program that would essentially run in a full window, and basically act like a mini operating system[/QUOTE] So you want to manually handle drawing of buttons and so on? C++ with SFML I'd say then.
[QUOTE=Larikang;39524838]Your main calls Game::Start which calls Game::GameLoop which calls Game::showMMenu which calls Menu::showMMenu which calls Text::create which [b]a ha![/b] finally calls Window::draw. I need to look at four different source files and five function calls before I know where the draw calls are occurring. There's technically nothing wrong with structuring things like that, but take a look at the end of the game loop in my Bananagrams clone: [cpp] window.clear(background); grid.draw_on(window); window.draw(cursor); window.draw(mcursor); display.draw(); messages.draw_on(window); window.display(); [/cpp] Even without seeing the rest of my code, it's pretty clear how I'm preparing the screen for each frame.[/QUOTE] How are you setting up those functions? [editline]9th February 2013[/editline] I really don't want to have to restructure my entire program to fix one annoying bug =\
[QUOTE=account;39507829]Shouldn't they be unsigned then, to allow for bytes > 127? I suppose a byte is a byte is a byte but it would make more sense to me at least[/QUOTE] Bytes >127 are already allowed. 128 is -128 and 255 is -1.
For my games programming course we have to create an xPilot clone, now so far we just have bounding circles for collision, but how would be the best way to check agains weird shape objects such as: [QUOTE][img]http://i.udm4.com/screenshots_u4win/66/66542_1.jpg[/img][/QUOTE]
Solved my problem.
Is there a way to declare a for a class that inherits two other classes?
[QUOTE=WTF Nuke;39529098]Is there a way to declare a for a class that inherits two other classes?[/QUOTE] Depends on the language, but usually yes [editline]9th February 2013[/editline] Im trying to implement a framerate limit, for it I have this in my main loop [cpp] long nanotime = System.nanoTime()/1000000; long deltaTime = 16; long aimedDelta = (long)(Constants.DT * 1000); while (game.playing()) { game.Update(); view.repaint(); if((aimedDelta - deltaTime) > 0){ Thread.sleep(aimedDelta - deltaTime); } deltaTime = (System.nanoTime()/1000000) - nanotime; nanotime = System.nanoTime()/1000000; System.out.println(deltaTime); } [/cpp] but my output is: [code]2 14 3 13 4 12 5 11 5 12 5 11 5 12 4 12 5 11 5 12 4 13 3 13 4 12 4 13 3 13 4 12 4 13 4 12 5 12 4 12 4 13 3 13 4 12 5 11 6 10 7[/code] So it must be something with the ordering or some issue because it seems 2 loops are taking the deltatime I want to achieve, ie 16ms, 60fps
[QUOTE=Richy19;39529172]Depends on the language, but usually yes[/QUOTE] Oops, I meant a pointer. Like a pointer to a class that derives from sf::Drawable and sf::Transformable.
Well you can create a pointer that points to the class you mean, say sf::Sprite, but I dont think you can do what your trying to do which is a pointer that points to any deried classes from both Drawable and Transformable
[QUOTE=ief014;39513381]This is how I used to draw circles in SDL a while back: [cpp] void drawCircle(SDL_Surface* surface, int x, int y, float rad, Uint32 color) { for (int offy = -(rad+1); offy < (rad+1); ++offy) for (int offx = -(rad+1); offx < (rad+1); ++offx) { float d2 = static_cast<float>(offx*offx + offy*offy); /* if (d2 < ((rad+1)*(rad+1))) { Uint32 modCol = color; d2 -= rad*rad; if (d2 > 0.f) { Uint8 r,g,b,a; SDL_GetRGBA(color, surface->format, &r, &g, &b, &a); d2 = 1.f - d2; r = static_cast<Uint8>(r*d2); g = static_cast<Uint8>(g*d2); b = static_cast<Uint8>(b*d2); a = static_cast<Uint8>(a*d2); modCol = SDL_MapRGBA(surface->format, r, g, b, a); } setPixel(surface, offx+x, offy+y, modCol); } */ if (d2 < (rad*rad)) setPixel(surface, offx+x, offy+y, color); } } [/cpp] However, that draws filled circles. If I remember correctly, the commented out code in there is the code to draw outlines.[/QUOTE] Could you paste your setPixel function? Thanks.
[QUOTE=ArgvCompany;39526435]So you want to manually handle drawing of buttons and so on? C++ with SFML I'd say then.[/QUOTE] Is c++ good with handling visual effects?
[QUOTE=Rob Markia;39529907]Could you paste your setPixel function? Thanks.[/QUOTE] [cpp] void setPixel(SDL_Surface* surface, int x, int y, Uint32 color) { // For debugging. // if (x < 0 || x >= surface->w || y < 0 || y >= surface->h) // return; memset( (unsigned char*)surface->pixels + y * surface->pitch + x * surface->format->BytesPerPixel, color, surface->format->BytesPerPixel ); } [/cpp] People here are probably going to hate that I use memset, but I found it to work pretty well.
[QUOTE=SIRIUS;39529990]Is c++ good with handling visual effects?[/QUOTE] It's not really C++ that's important here (but to answer your question, Windows is written in it, or at least parts of it, it's the (or one of the) most popular language for games), it's more SFML, since it lets you do a lot of advanced stuff, while still keeping it pretty simple.
[QUOTE=SIRIUS;39529990]Is c++ good with handling visual effects?[/QUOTE] That question doesn't exactly make sense. C++ can produce fast code, which is often desirable when it comes to real-time graphics. What sort of visual effects you get depends on the library you use, and different libraries are available for different languages.
[QUOTE=Gulen;39530188]It's not really C++ that's important here (but to answer your question, Windows is written in it, or at least parts of it, it's the (or one of the) most popular language for games), it's more SFML, since it lets you do a lot of advanced stuff, while still keeping it pretty simple.[/QUOTE] Why sfml over something like openGL?
Because with openGL, you'd have to do all the bottom-line stuff yourself, like opening a window and handling all its events. With SFML, it wraps all that into a nice little framework, while it still lets you do manual OpenGL stuff if you want to.
I haven't really researched this, but I want people's opinions on fpp first. Is there such thing as "learning the basics" in C++? I've been frightened by other people saying how hard C++ and I'll never get anywhere. I know C++ is a low language, but is it readable? Should I skip all other languages in to learning C++ from a book or something.
Yes, C++ is readable, but most of the time you'll be ready stuff other people made, like SFML, SDL or even Windows (though I doubt Windows is going anywhere, so learning that isn't dumb), or whatever other people made. So these functions have different arguments and do different stuff with them, so you can't just look at a piece of code and know exactly what it does. But you can look around a little and figure it out. (but you'll have to look at different files or APIs)
[QUOTE=SiPlus;39527077]Bytes >127 are already allowed. 128 is -128 and 255 is -1.[/QUOTE] -128 and -1 are <127.
Unsigned or signed you can still represent 256 different values, but it would make more sense to me to have them unsigned so you could say "this character is represented by 45 followed by 204" than "45 followed by -52"
[QUOTE=jung3o;39531502]I haven't really researched this, but I want people's opinions on fpp first. Is there such thing as "learning the basics" in C++? I've been frightened by other people saying how hard C++ and I'll never get anywhere. I know C++ is a low language, but is it readable? Should I skip all other languages in to learning C++ from a book or something.[/QUOTE] It certainly isn't the most efficient way to learn C++, but I recommend learning C first. In a sense it is "the basics" of C++, and will make the cool features of C++ seem that much cooler. The only problem is that you will need to unlearn some C stuff when you switch to C++, but as long as you're mindful of that it shouldn't be an issue.
I am working on a mediafire wrapper for a python and I am not sure whether I should make everything a single class or put user, file, folder and upload into separate classes [URL="https://github.com/superstepa/Mediafire_Wrapper/blob/32c65d7306bc92aeb196a6bfc25c106d823c065b/mediafire.py"]single class[/URL] [URL="https://github.com/superstepa/Mediafire_Wrapper/blob/04037dfe8d76b9e23695b177ac8b2b9e4d9c1237/mediafire.py"]multiple classes[/URL] If I leave it in multiple classes it's way neater, but if I leave it in single class it's possible to call file functions by just calling mainclass.file_functionname(file_key,other parameters) What do you guys think?
Most modules I've seen that talk to some service (last.fm, MySQL, etc) do it single-class, so my vote is that.
I simply cannot wrap my head around how classes work. I'm on [URL="http://learnpythonthehardway.org/book/ex40.html"]Exercise 40[/URL] in Learn Python the Hard Way, a great book so far that has helped me finally get into programming. The code in question is this: [code]class Song(object): def __init__(self, lyrics): self.lyrics = lyrics def sing_me_a_song(self): for line in self.lyrics: print line happy_bday = Song(["Happy birthday to you", "I don't want to get sued", "So I'll stop right there"]) bulls_on_parade = Song(["They rally around the family", "With pockets full of shells"]) tribute = Song(["Look into my eyes and it's easy to see", "One and one make two, two and one make three." "It was destiny."]) happy_bday.sing_me_a_song() bulls_on_parade.sing_me_a_song() tribute.sing_me_a_song()[/code] The thing that really confuses me is what the hell self.lyrics does in the __init__ module. Not only that, but how it's used in the sing_me_a_song module's for-loop, all in the class Song. I just simply don't get it. self.lyrics confuses me a ton. I don't understand how passing the object to Song simply transfers to lyrics, if it does that. Can anyone help me out?
It's a constructor. If you create an object you can pass arguments to it, in this one it just sets self.lyrics to what you pass it
I've got a question about C++ and Visual Studio, when you hover over classes on C# or java it shows a popup with the appropriate documentation, on C++ I get some code which I don't quite understand yet with the standard library. Is that normal?
Sorry, you need to Log In to post a reply to this thread.