www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/22/05:50:15

From: "big choi" <supercms AT netian DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Help me plz!! Allegro..
Date: Thu, 22 Oct 1998 19:43:46 +0900
Organization: Seoul National University, Republic of Korea
Lines: 215
Message-ID: <70n1mj$csc$1@news.kren.nm.kr>
NNTP-Posting-Host: 210.110.145.61
X-Newsreader: Microsoft Outlook Express 4.72.2106.4
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Help me plz!!
this is my source..
My question checked..

#include <allegro.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

#define Width 30
#define Height 30
#define _Width 15
#define _Height 15
#define True 1
#define False 0
#define max_num 5
#define bullet_h 6

DECLARE_GFX_DRIVER_LIST
(
GFX_DRIVER_VGA
);

typedef unsigned char byte;
typedef unsigned short word;

BITMAP *back, *me, *enemy1, *enemy2;
BITMAP *video;
PALLETE pal;
short x=145, y=169;
byte isEnemy=False;
byte isBullet=False;
byte isebullet=False;

struct my{
short x;
    short y;
    short isMyplane;
}myPlane;

struct Enemy{
short x;
    short y;
    short vx;
    short vy;
    short isEnemy;
}enemy[5];

struct Bullet{
short x;
    short y;
    short isBullet;
}bullet[5];

struct eBullet{
short x;
    short y;
    short isebullet;
}ebullet[5];

void CreateEnemy();
void end();
void init();
void load_pcx();
void MoveEnemy();
void play();
void PutSprite(short x, short y, byte * image);
void read_pallete();

byte shoot[]={4, 0, 6, 0,
     0,14,14, 0,
    14,14,14,14,
     0,14,14, 0,
     0,14,14, 0,
     0,14,14, 0,
     0,14,14, 0};

void CreateEnemy()
{
word i=0;
for (i=0; i<max_num; i++)
{
  if (enemy[i].isEnemy == False)
  {
   enemy[i].x = srandom(270);
   //Is this correct?
   //I want to select between 1 and 270.
   //I write  random(270) to Borland turbo c.
   //Allegro find "error message"..
   enemy[i].y = 0;
   enemy[i].isEnemy = True;
  }
}
}

void end()
{
    destroy_bitmap(back);
    destroy_bitmap(me);
    destroy_bitmap(enemy1);
    destroy_bitmap(video);
}

void init()
{
    allegro_init();
    set_gfx_mode(GFX_VGA,320,200,0,0);
    install_keyboard();
}

void load_pcx()
{
    word i=0;

    blit(back,video,0,0,0,0,320,200);
    masked_blit(me,video,0,0,x,y,30,30);
    masked_blit(enemy1,video,0,0,enemy[i].x,enemy[i].y,30,30);
    //Write here..See enemy picture..but not move..
    blit(video,screen,0,0,0,0,320,200);
}

void MoveEnemy()
{
    word i=0;
    word vx=1, vy=1;

for(i=0; i<max_num ;i++)
{
   if(enemy[i].isEnemy == True)
   {
   if(enemy[i].x > 100)
   {
   enemy[i].vx = -enemy[i].vx;
   }

   if(enemy[i].x > 200)
   {
   enemy[i].vx = -enemy[i].vx;
   }

   if(enemy[i].x < 0)
    enemy[i].vx = -enemy[i].vx;

   if((enemy[i].x  + Width) > 319)
    enemy[i].vx = -enemy[i].vx;

   enemy[i].x = enemy[i].x + enemy[i].vx;
   enemy[i].y = enemy[i].y + enemy[i].vy;

   if((enemy[i].y) > 199)
    enemy[i].isEnemy = False;

   masked_blit(enemy1,video,0,0,enemy[i].x,enemy[i].y,30,30);
  //Write here..Don't see enemy picture.
   }
}
}

void play()
{
    word i=0;
read_pallete();

    while(1)
    {
     if(key[KEY_ESC])    {remove_keyboard(); break;}
     if(key[KEY_UP])     {if(y>0-Height) y--;}
     if(key[KEY_DOWN])   {if(y<199) y++;}
     if(key[KEY_RIGHT])  {if(x<319) x++;}
     if(key[KEY_LEFT])   {if(x>0-Width) x--;}
     if(key[KEY_SPACE])
        {
      for (i=0; i<max_num; i++)
      {
       if (bullet[i].isBullet == False)
       {
        bullet[i].x = x+_Width-2; // center
        bullet[i].y = y;
        bullet[i].isBullet = True;
        break;
       }
      }
      }

    load_pcx();
         CreateEnemy();
         MoveEnemy();
    }

}

void read_pallete()
{
    video=create_bitmap(320,200);
    clear(video);

    back=load_pcx("back2.pcx",pal);
    me=load_pcx("me.pcx",pal);
    enemy1=load_pcx("enemy.pcx",pal);

    set_pallete(pal);
}

int main()
{
    init();
    play();
    end();
    return 0;
}

My email is supercms AT netian DOT com
Thanks.


- Raw text -


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