File: DEMO.C | Size: 3,224 bytes | Download file | Back to directory listing | BWPOW's homepage
#include <allegro.h>
#include "main.h"
#include "things.h"
 
void demo(int dem)
{
  int pos=0;
  unsigned char c,i;
  unsigned char t[7];
  char text[50],s,text2[50],text3[50];
  char tbuf[20];
 
  info.demo=1;
 
 
  // dem
  sprintf(tbuf,"ldmo%0004d.dmo",dem);
  demos=load_datafile_object("xmas.dat",tbuf);
 
  dem=0;
 
  while(c!=206)
  {
    c=((unsigned char *)demos[0].dat)[pos]-48;pos++;
 
    if(c==0){ // Chod
      t[0]=((unsigned char *)demos[dem].dat)[pos];pos++;
      t[1]=((unsigned char *)demos[dem].dat)[pos];pos++;
      trajectory(info.x,info.y,t[0],t[1]);
      info.t=0;
      t[2]=1;
      while(t[2]!=0){
        if(info.tim!=info.otim){
          info.otim=info.tim;
          t[2]=_walk(t[0],t[1]);
          draw_scene();
          vsync();
          blit(bmp,screen,0,0,0,0,640,480);
        }
      }
      info.m=0;
      draw_scene();
      vsync();
      blit(bmp,screen,0,0,0,0,640,480);
    }
 
    if(c==1){ // hovor
      t[0]=((unsigned char *)demos[dem].dat)[pos];pos++;
      t[2]=0;t[1]=1;
      while(t[1]!=0){
        t[1]=((char *)demos[dem].dat)[pos];pos++;
        text[t[2]]=t[1];t[2]++;
      }
 
      t[2]=0;t[1]=1;
      while(t[1]!=0){
        t[1]=((char *)demos[dem].dat)[pos];pos++;
        text2[t[2]]=t[1];t[2]++;
      }
 
      t[2]=0;t[1]=1;
      while(t[1]!=0){
        t[1]=((char *)demos[dem].dat)[pos];pos++;
        text3[t[2]]=t[1];t[2]++;
      }
 
      sprava(text,text2,text3,t[0]);
      _upgrade_text();
//      draw_scene();
//      info.m=0;
//      vsync();
//      blit(bmp,screen,0,0,0,0,640,480);
    }
 
    if(c==2){ // anim
      t[0]=((unsigned char *)demos[dem].dat)[pos];pos++;
      t[1]=((unsigned char *)demos[dem].dat)[pos];pos++;
      t[2]=((unsigned char *)demos[dem].dat)[pos];pos++;
      t[3]=((unsigned char *)demos[dem].dat)[pos];pos++;
      t[4]=((unsigned char *)demos[dem].dat)[pos];pos++;
 
 
      s=t[2]-t[0];
 
      obj[t[4]].x=t[0];
      obj[t[4]].y=t[1];
 
      for(i=0;i<abs(s);){
        if(info.tim!=info.otim){
          info.otim=info.tim;
          i+=t[3];
          if(s<0) t[0]-=t[3];
          else t[0]+=t[3];
          obj[t[4]].x=t[0];
          draw_scene();
          info.m=0;
          vsync();
          blit(bmp,screen,0,0,0,0,640,480);
        }
      }
      draw_scene();
      info.m=0;
      vsync();
      blit(bmp,screen,0,0,0,0,640,480);
    }
 
    if(c==3){ // zmen room
      t[0]=((unsigned char *)demos[dem].dat)[pos];pos++;
      fx();
      info.room=t[0];
      info.x=((unsigned char *)demos[dem].dat)[pos];pos++;
      info.y=((unsigned char *)demos[dem].dat)[pos];pos++;
      load_room(info.room);
      _init_predmet();
    }
 
    if(c==5){ // pridaj predmet
      t[0]=((unsigned char *)demos[dem].dat)[pos];pos++;
      add_to_invent(t[0]);
      draw_invent();
      vsync();
      blit(bmp,screen,0,0,0,0,640,480);
    }
 
    if(c==4){ // odstran predmet
      t[0]=((unsigned char *)demos[dem].dat)[pos];pos++;
      remove_from_invent(t[0]);
      draw_invent();
      vsync();
      blit(bmp,screen,0,0,0,0,640,480);
    }
 
    if(c==7){
      room[info.room].demo=((unsigned char *)demos[dem].dat)[pos];pos++;
    }
 
 
    pos+=2;
  }
 
  info.demo=0;
  unload_datafile_object(demos);
}