Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

154 Neutral

About mattor

  • Rank
  1. I was getting strange errors on recompilations of programs that worked fine about two weeks ago, and I have made no changes. It said 'msvcr71.dll' could not be found. Well I uninstalled dev-c++ and then reinstalled it, and it got rid of that error, but now I have a new one. It doesn't compile my programs properly anymore. First of all I get all these warnings that the allegro functions I'm using (textprintf, text_mode) are 'deprecated', which it never mentioned before. On top of that, it will compile but it won't run! It doesn't create an .exe file or anything. Anyone know why this is or how to solve it?
  2. mattor

    Bitmap fonts

    Hey, I experimented with Cones tuts as well, and the only way I got new fonts other than the two he included was by downloading that bitmap font builder he links to in the first tutorial that uses fonts. It uses an SDL structure called SDLFont, but you have to set the size and so on in that LMNOpc Bitmap Font Builder. Because of weirdness with the fonts, and depending how new you are, I found allegro to be much easier. The fonts were weird there too, but overall Allegro was easier for me as a beginner. There are also additional libraries with SDL that supposedly make fonts easier, so you can use TTFs and other fancy shmancy things. Someone around here will know what the best libraries are, but like I said, Allegro was a much quicker start for me.
  3. mattor

    Black Jack Program, C++

    Hey, glad to see someone else trying was my first game ever and man was it harder than I thought it should be. Anyway, the first thing that sticks out is that you might be dealing repeat cards, since you're using randomness WITH replacement. Then again, to simulate multiple decks I guess it's pretty close to reality. What I did instead of a switch was something (roughly) like this: bool gameover = false; while(!gameover) { placeBet(); //place the bet shuffle_cards(); //basically just std::random_shuffle in algorithm.h dealFirstCards(); //deals first two cards PlayersHand(); //goes through the players turn CompsHand(); //does computer's hand dispWinner(); //determine who won and print it out, ask for quit resetVars(); //sets things back to true/false/0, like dealer_tot //and player_tot, etc. } This may be a huge change and not exactly what you were asking, but having everything in this one loop eliminates the need for some of the complicated input handles. I can post more code if you want, once I get to my other computer. this is just the main game loop and you have to write each of those functions, BTW.
  4. mattor

    allegro bitmap stuff

    I thought I read on a post somewhere that -> used to be the way to do it, but not so c used -> and c++ added the . feature. Is that -> for pointers a convention or a necessity?
  5. mattor

    allegro bitmap stuff

    I guess if you already have the bitmap as a file, you could change my above post to: BITMAP *bg_tile = load_bitmap("tile.bmp",NULL); Then, instead of tile.width and tile.height, you can just access that with bg_tile.w and bg_tile.h. Those two (.w and .h) are automatically put in there as the size of the loaded bitmap, so they will both be 32. You can use them right away. Also, if your pattern has a transparent color in it, you can change the blit() line to a masked_blit(). Of course, smart_idiot's idea is a bit simpler. And remember to destroy() your bitmap when you're done with it (like at program exit) or you can cause wormholes in the universe. Good luck Mattor
  6. mattor

    allegro bitmap stuff

    how about: int i, j; BITMAP *bg_tile = create_bitmap(tile.width,tile.height); for(i=0; i <= (SCREEN_W-bg_tile.w); i+=tile.width) for(j=0; j <= (SCREEN_H-bg_tile.h); j+= tile.height) { blit(bg_tile, screen, 0, 0, i, j, bg_tile.w, bg_tile.h); } This maybe could work. It should blit the tile onto the screen column-by-column, if you want to do it row-by-row you can just switch the two for() lines.
  7. mattor

    Using basic animation

    There's a book called 'Game Programming All In One" by Jonathan S. Harbour that uses Allegro (easy to use) throughout. He walks you through a game called...Tank War!!! and updates it each chapter with more advanced stuff. I'm using to book to learn general stuff but it's right up your alley if you want to do a tank game.
  8. mattor

    Scrolling the screen

    EXCELLENT! Thanks guys. I just switched to blitting twice and it worked. All in about 4 lines of code. One more question though...when I blit the background right to the screen it works fine, pretty quick, etc. But when I try to blit the 'two' backgrounds to a buffer and THEN blit the buffer to the screen, it slows to an agonizing crawl. Why is that, and how can I avoid it?
  9. I wrote some Allegro code to display a randomly generated starfield and then to scroll it. Here's the code: void move() { int i, j; int temp[WIDTH]; for(i=0;i<WIDTH;i++) temp = getpixel(starbg,i,HEIGHT-1); blit(starbg,starbg,0,0,0,1,WIDTH,HEIGHT); for(i=0;i<WIDTH;i++) putpixel(starbg, i,0,temp); } int main() { starteverything(); buffer = create_bitmap(WIDTH,HEIGHT); stars(); clear_bitmap(buffer); starbg = load_bmp("starscreen.bmp",NULL); blit(starbg,screen,0,0,0,0,WIDTH,HEIGHT); do{ move(); blit(starbg,screen,0,0,0,0,WIDTH,HEIGHT); }while(!key[KEY_ESC]); destroy_bitmap(starbg); destroy_bitmap(buffer); allegro_exit(); return 0; } END_OF_MAIN(); Well that's as much of the code that matters anyway. Believe it or not, this code works just fine. The only problem is it's too slow. There must be a faster way to do this? I mean it's smooth and it delivers the correct effect, but I'm sure I could be doing this more effectively. So how do I? Thanks in advance.
  10. mattor

    Background Question

    Hey I'm trying to do something very similar to this article too, but my task is to scroll simulated stars like in a space shooter. Using 2D graphics (allegro), first I generate a bitmap that is twice the height of the screen. Then I save it as an actual .bmp file, then later load that static file as my background. At the top of my game loop I had a function movestars() that would peel one line off the bottom of the bitmap, shift everything down one pixel, then paste the temp line back on top, thus moving stars. Well, it didn't work very well at all, and it made my program WAY too slow. To make a long question longer, what is a good way of scrolling stars without slowing up the game too much?
  11. mattor

    How do text games work?

    I'm not sure if you're still trying to find a new API but I switched from SDL to Allegro because it was much easier for me to understand. Both are documented pretty well, except for font info concerning Allegro. But it's easily doable using the grabber, and I've found it to be easier to get a project up and running quicker using Allegro. That's just two pennies.
  12. I have a question that's not really specific to any API or platform, development. I'm making a Space Invaders type thing, and I've got different types of enemies (they move at different speeds, have corresponding point values, and so on). My question is, how can I decently handle the spawning of these enemies? Right now I have two enemies and two timers, one for each type of enemy. I'm sure there is some smarter way of doing this. Here's a bit of the code I have: if(timer1>=4000) { enemy[0].alive = true; enemy[0].x = -enemy[0].width; enemy[0].y = 15; timer1 = 0; } if(timer2>=6000) { enemy[1].alive = true; enemy[1].x = -enemy[1].width; enemy[1].y = 10; timer2=0; } ... timer1 += DELAY; timer2 += DELAY; So it spawns an enemy[0] every 4 seconds and an enemy[1] every 6 seconds. But is there a less clunky way of doing this than what I've got here? (The DELAY is rest(20) if that matters) What do people normally do for this type of stuff?
  13. This is more general than most questions on this site, but I'm a little stumped. I've been dabbling in learning the basics and making some simple games as exercises for learning the API (allegro) and refreshing my c++ skills. But now I'm ready to actually do something new and creative with it and I'm not sure how to go about it. Where do you get ideas for games once you get beyond mimicking classics as exercises? I know this is probably an impossible question to answer as a rule, but just curious where people draw inspiration from. I started making a space invaders type game but I want to actually feel like there's a purpose for me making the game, to add some new feature or some reason to actually get on with it. Any suggestions?
  14. Okay coders maximus: I am using allegro and dev-c++. I am trying to write a simple space invaders type deal where the ship only moves left and right at the bottom of the screen. I have implemented double buffering with the theory in mind that I can paint everything to the buffer, then flip the buffer to the screen when it's all done so as to avoid flickering. So when I try to do that, I *still* get flickering. WHY must it always be this way? The ship is what flickers, not the background. Here's my code: buffer = create_video_bitmap(WIDTH,HEIGHT); do{ erase(ship); move(ship); draw(ship); blit(buffer,screen,0,0,0,0,WIDTH,HEIGHT); rest(10); }while(!key[KEY_ESC]); and the three functions: void erase(CShip ship) { int left = ship.x-SPEED; int right = ship.x + ship.width +SPEED; int h = HEIGHT-ship.height; rectfill(buffer,left,h,right,HEIGHT,DBLUE); } void move(CShip &ship) { if(key[KEY_LEFT]) ship.x -= SPEED; if(key[KEY_RIGHT])ship.x += SPEED; if(ship.x < 0) ship.x =0; if(ship.x > WIDTH-ship.width) ship.x = WIDTH-ship.width; } inline void draw(CShip ship) { int h = HEIGHT-ship.height; rectfill(buffer,ship.x,h,ship.x+ship.width,HEIGHT,ship.color); }
  15. mattor

    Allegro memory deallocation

    what do you put inside the destructor definition, and how do you use the destructor? (if I've written my own class)
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!