www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/28/01:46:18

From: Drizzle <drysle AT rocketmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro: Background
Date: Sat, 28 Feb 1998 00:36:50 -0600
Organization: AT&T WorldNet Services
Lines: 82
Message-ID: <6d8b9h$en0@bgtnsc02.worldnet.att.net>
References: <34F51654 DOT F1A7B81E AT mailbox DOT uq DOT edu DOT au> <19980226171400 DOT MAA04739 AT ladder02 DOT news DOT aol DOT com>
NNTP-Posting-Host: 12.67.2.37
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Alright, I'll get to work on this.. This is my first game, but I might be able to
get it working.. If it doesn't I'll try Dirty Rectangle's..

QBallLives wrote:

> >
> >> I'm having trouble blitting a background to a simple Pong Game I'm
> >> making with DJGPP and Allegro. Before I put the code in to put a
> >> background bmp file in, it ran fine, at just the right speed.  After It
> >> started going slower and the Ball moves 'choppy'.  Is there anyway I can
> >> only have the bitmap drawn once without it have to redraw the whole
> >> thing every frame?  Right Now i'm using double buffering, I was thinking
> >> of trying Dirty Rectangles if that would go quicker.  Anyways, here's
> >> the code, If you have any suggestions, I'd be greatful..   Thanks in
> >> Advance..  Oh yeah, also if you have any info on how I could make it run
> >> as slow/fast on all machines(A pentium 300 won't go too much(or any)
> >> faster than a 486, or low-end pentium.)
> >>
> >> This is just the bottom portion of the C source file..
> >
> >One thing you could do is have a background preset just before the main loop.
> >Then copy the bitmap to another temp
> >
> >bitmap (double buffering) on which everything is drawn.
> >
> >
>
> What you really need is a Sprite_Under function and a Sprite_Erase function...
> A good thing to do to start with is add a little background buffer to your
> sprite structure (assuming you're using a structure)
>
> The concept is this... you blit the background one time (outside of the main
> event loop)
>
> Next, before you BLIT - copy a rectangle from the background (the same size as
> the sprite you'll be drawing) - from the position where you're going to draw
> the sprite...
>
> Then, whenever you get around to drawing the next frame - you don't need to
> blit the background again - you can simply blit the background copy you made
> before you put the sprite down (erase)
>
> Get the 32-bit code suppliment to the Black Art of 3D Game Programming - by
> Andre' Lamothe (waite group press)
>
> it's available at http://www.waite.com/waite
>
> The chapter 4 material from the book would be most helpful to you
> here....Though the code will have to be adapted a little bit for DJGPP - I
> wouldn't call it a hard port.
>
> Here's the way it could look in the event loop
>
> // blit the background where this comment is...
> // set the initial position for the sprite here
>
> Sprite_Under((sprite_ptr)&sprite,sprite.curr_x,sprite.curr_y);
>
> while(!done)
> {
>          // the following line is just like the Draw_Sprite function
>          // except that it's blitting the background buffer..
>
>          Erase_Sprite((sprite_ptr)&sprite,sprite.curr_x,sprite.curr_y);
>
>           // stuff to move the sprite, or make !done = 1... or whatever
>           // goes here...
>          // changing sprite.curr_x... etc...
>
>          Sprite_Under((sprite_ptr)&sprite,sprite.curr_x,sprite.curr_y);
>
>          Draw_Sprite((sprite_ptr)&sprite,sprite.curr_x,sprite.curr_y);
> }
>
>
>
> Jim the loiterer
> aloiterer AT juno DOT com
> http://www.fortunecity.com/skyscraper/gigahertz/179/index.html



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019