delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/20/17:31:14

To: djgpp AT delorie DOT com
Subject: How fast can you get in 640x480? (allegro)
Message-ID: <19970520.172639.7119.5.fwec@juno.com>
From: fwec AT juno DOT com (Mark T Logan)
Date: Tue, 20 May 1997 17:27:10 EDT

Greetings.

I am working on a birds eye view type crpg, ala final fantasy.
I am trying to get it to work in 640x480x256 using allegro.  I
have had very little success so far.  the fastest I can get is
about 18-20 fps.  I am just wondering if my code is stupid, and
I should keep trying, or if you can't really get that fast in 640x480.



Here is the fastest approach so far.

--------------------------------------------------------------------------------
#include <allegro.h>

#include "rpg.h"

int main()
{
 int i, j, x_adjust = 0, y_adjust = 0;

 char switcher = 1;

 DATAFILE *data;

 data = load_datafile("rpg.dat");

 allegro_init();
 install_keyboard();

 set_gfx_mode(GFX_AUTODETECT, 640, 480, 1280, 480);

 set_clip(screen, 0, 0, 1279, 479);

 set_pallete(data[game_pal].dat);

 while(!key[KEY_ESC])
  {
   switcher = !switcher;

   if(key[KEY_RIGHT])
    x_adjust -= 1;
   if(key[KEY_LEFT])
    x_adjust += 1;
   if(key[KEY_UP])
    y_adjust += 1;
   if(key[KEY_DOWN])
    y_adjust -= 1;

   for(i = 0; i < 20; i++)
    {
     for(j = 0; j < 15; j++)
      {
       if(switcher)
        draw_sprite(screen, data[generic_floor].dat, (i<<5) - x_adjust,
(j<<5) - y_adjust);
       else
        draw_sprite(screen, data[generic_floor].dat, (i<<5) - x_adjust +
640, (j<<5) - y_adjust);
      }
    }

   if(switcher)
    scroll_screen(0, 0);
   else
    scroll_screen(640, 0);
  }
}

--------------------------------------------------------------------------

Please note that this is just a test prototype
to see if I can get something running fast enough.
It wouldn't actually be acceptable for the game.

Am I going about this in the completly wrong way?  I've
never actually seen any working code for a game of this
type, so I just made this approach up.

Never again will I assume a project is as easy as it sounds.

TIA
fwec AT juno DOT com

- Raw text -


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