MrMonkeh

Member
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

130 Neutral

About MrMonkeh

  • Rank
    Newbie
  1. C++ % Operator Problem

    I believe the modulus operator (%) only works with integer types. You'll have to convert fn and sn to integer if you want to use it. Or...a quick search on google and I stumbled upon "fmod". Used like so: [CODE] fmod(5.5, 3.5) // takes numerator and denominator [/CODE] Note: I've never used this function before, so no promises. Though I believe you need to include the math header file to use fmod.
  2. Allegro moving rectangle help

    [quote name='Wooh' timestamp='1317892687' post='4869719'] There are many ways to make updates to the screen. One simple way is to redraw everything every frame. This way is very easy. Doing like you are trying to do, drawing the background over the previous location of the paddle, should work fine in this simple case with single coloured background and non overlapping objects. You should call this before updating y1 and y2. [code]rectfill(screen,x1,y1,x2,y2,0);[/code] Also get rid of the calls to [i]rest[/i] here. I don't see why you have them here. You know what [i]rest[/i] do, do you? It waits the number of milliseconds. This might explain why you get "flicking black". If you want to call [i]rest[/i] do that somewhere else once per frame instead. Your approach is probably faster than redrawing everything every frame but the question is how much? Does it really matter? I have never used Allegro so I don't know. [/quote] I have the rest to actually control how fast the box moves. When I take the rest out, you see a quick flicker of white, and the box is way gone out of the picture.
  3. Hi, I have a simple question, probably super easy too, so I'd appreciate if someone could help me out here! I'm trying to recreate Pong, but far from that...I'm at the stage of getting things on the screen Basically, I want to move the rectangles on the sides, but can't figure out how in a productive manner. And before I get any farther, I am running Allegro 4.2, not the new version, 5. I have this code: [code]if (key[KEY_S]) { y1++; rest(10); y2++; rest(10); rectfill(screen,x1,y1,x2,y2,15); }[/code] Sorry if it looks weird, trying to figure out how to put code on here...[i]anyways...[/i]Basically for anyone who has ran Allegro, this simply redraws another rectangle, so it ends up looking like there's a rectangle on the whole left side. I've tried doing [code] rectfill(screen,x1,y1,x2,y2,0);[/code] to sort of "erase" it, but then when moving it just looks horrible (flicking black). Any help would be appreciated, or point me in the right direction! Thank you, MrMonkeh
  4. Beginning Game Programming

    [quote name='Serapth' timestamp='1316897964' post='4865564'] [quote name='MrMonkeh' timestamp='1316845108' post='4865406'] Hi everyone! I've been reading the forums for a few days now and finally broke down and made an account to see if I could get your opinions... To start off, yes I have been teaching myself C++ for awhile now, and I got most of the basics down, and learning more advanced such as objects and classes, etc... Simply speaking though, I am wanting to get into game programming, whereas right now I am solely doing programming. What would be the best option (and/or tool) for me to add gaming to my programming list? Obviously since I have no prior experience in the gaming programming field, I want to start off very basic, such as 2D. I've read about Allegro and seen it to be a good starting position, though I was unsure of how good of quality you can make with it alone. And yes I've read through other posts, I've seen other engines and such, and I know this question has been asked a million times before. I just want to know where my best start would be with C++, as I've been getting various answers everywhere...so I want real programmer's opinions. Any and all advice will be greatly appreciated, please feel free to throw anything you have out here, even if it's the most basic of all programming. I just want a place to start, and possibly something I could grow into a larger field. Thanks for reading! -MrMonkeh [/quote] First, my biggest advice would be not to start with C++, but then, nobody ever listens to that one bit of advice for whatever reason... If you are indeed going to go ahead with C++ [url="http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition.aspx#CPlusPlus"]I put together this link[/url] that contains tool, book and library recommendations for learning C++ for game programming. Also, I am doing a [url="http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition.aspx"]longer tutorial series[/url] on writing a game in C++ using SFML. It goes into a lot more depth than most tutorials and hopefully will make you a better C++ programmer as a result. Most tutorials focus on a specific feature or are simply bad code, leading to a very bad foundation for new programmers to start with, hopefully this series of tutorials results in some slightly better beginner code. Still a WIP though, so not complete yet. [/quote] I recently read that on this site and wished I would have seen this BEFORE getting a good deal into C++. I own the C++ for Dummies Reference all-one-book (and I'm not sure how you guys feel about dummies books, so don't make fun ) and am about 300 pages in. I guess technically I could switch to a different language, though I am far into it (or so I think) and in my eyes it seems like I should just stay with it...however, if you feel a different one, such as C# would be better, even at this point then let me know before I drag myself deeper! I do appreciate it though, I will check out the links and tutorials you gave. On another note, if I do stay with C++, shall I continue learning it completely (ie; finish the book first) before attempting to fiddle with the gaming side? Or go ahead and start messing with gaming programming? Thanks!
  5. Beginning Game Programming

    Hi everyone! I've been reading the forums for a few days now and finally broke down and made an account to see if I could get your opinions... To start off, yes I have been teaching myself C++ for awhile now, and I got most of the basics down, and learning more advanced such as objects and classes, etc... Simply speaking though, I am wanting to get into game programming, whereas right now I am solely doing programming. What would be the best option (and/or tool) for me to add gaming to my programming list? Obviously since I have no prior experience in the gaming programming field, I want to start off very basic, such as 2D. I've read about Allegro and seen it to be a good starting position, though I was unsure of how good of quality you can make with it alone. And yes I've read through other posts, I've seen other engines and such, and I know this question has been asked a million times before. I just want to know where my best start would be with C++, as I've been getting various answers everywhere...so I want real programmer's opinions. Any and all advice will be greatly appreciated, please feel free to throw anything you have out here, even if it's the most basic of all programming. I just want a place to start, and possibly something I could grow into a larger field. Thanks for reading! -MrMonkeh