⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 anim.c

📁 一个runtils v2.0图形音乐库的demo程序
💻 C
字号:
/*============================================================================*/
/*   PROJECT NUCLEUS.      (c) RocSoft, 1995.                                 */
/*   v1.0  18 Jan 95.                                                         */
/*============================================================================*/

#include <rgenrl.h>
#include <rgraph.h>
#include <rsprite.h>
#include <rinout.h>
#include <rfileio.h>
#include <rsound.h>
#include <rblast.h>
#include <rmem.h>
#include <rmath.h>
#include "\rocco\glib\games.h"

#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>

#include "defines.h"
#include "prototyp.h"
#include "globals.h"

extern int       Logo_Control[14];
extern int       Power_Up_Delay;

/*================[ Functions For Background Replacement ]====================*/

void Colour_Cycle_Switcher( int page )
{
    unsigned char  *buff=Pal.pal;

    showpage( page );     /*  VR in progress on exit  */
    _asm
    {
        les    bx, buff
        add    bx, FRACTAL_CYCLE_COLOUR_1
        mov    cx, FRACTAL_CYCLE_COUNT
        add    cx, 3
        mov    dx, 03C8H
        mov    al, FRACTAL_COLOUR_REG_1
        out    dx, al
        inc    dl
    Repeat:
        mov    al, es:[bx]
        out    dx, al
        inc    bx
        loop   Repeat
    }
}

/*===================[ Functions For AUTOMATON Control ]======================*/

int  Beam_Mover( void *object, int *x, int *y )
{
    BEAM   *b=Cfg.beams + ((OBJECT *)object)->pri - BEAM_TOON_BASE_PRI;

    *x = (b->x+=b->vx);

    if ( *x<0 || *x>VX_MAX )
    {
        b->active = FALSE;
        return( DELETE_OBJECT );
    }

    return( ACTIVE_OBJECT );
}

int  Counter_Mover( void *object, int *x, int *y )
{
    int     i=((OBJECT *)object)->pri - COUNTER_TOON_BASE_PRI;
    NUCLEUS *n=Cfg.nuclei+i;
    SPRITE  *s=Counter_Icons+n->cframe;

    *x = n->cx - (s->w>>1);
    *y = n->cy - (s->h>>1);

    return( ACTIVE_OBJECT );
}

int  Logo_Mover( void *object, int *x, int *y )
{
    OBJECT   *o=object;
    int      *pri=Logo_Control+o->pri;

    if( *pri )
    {
        if ( o->pri<7 )    /*   Top line   */
        {
            if ( (*y)<LOGO_TL_Y ) (*y)++; else (*pri)++;
        }
        else
        {
            if ( (*y)>LOGO_BL_Y ) (*y)--; else (*pri)++;
        }
    }

    if ( (*pri)==2 ) putimg( o->toon->img+o->idx,*x,*y,2 );

    return( ((*pri)==3)?DELETE_OBJECT:ACTIVE_OBJECT );
}

int Particle_Mover( void *object, int *x, int *y )
{
    OBJECT    *o=object;
    int       idx=o->pri-PARTICLE_TOON_BASE_PRI;
    PARTICLE  *p=Cfg.particles+idx;
    SPRITE    *s=SParticles+p->type;

    *x = p->x - (s->w>>1);
    *y = p->y - (s->h>>1);

    return( ACTIVE_OBJECT );
}

int PowerUp_Mover( void *object, int *x, int *y )
{
    if ( (*x) > VX_MAX ) return( DELETE_OBJECT );

    (*x)++;

    return( ACTIVE_OBJECT );
}

int Rogue_Mover( void *object, int *x, int *y )
{
    OBJECT    *o=object;
    int       idx=o->pri-ROGUE_TOON_BASE_PRI;
    SPRITE    *s=RogueParticles+o->idx;
    PARTICLE  *p=Cfg.rogues+idx;

    *x = p->x - (s->w>>1);
    *y = p->y - (s->h>>1);

    return( ACTIVE_OBJECT );
}

int Shield_Mover( void *object, int *x, int *y )
{
    SHIELD    *s=Cfg.shields + ((OBJECT *)object)->pri - SHIELD_TOON_BASE_PRI;

    *x = s->x - s->rx;
    *y = s->y - s->ry;

    return( ACTIVE_OBJECT );
}

int Syringe_Mover( void *object, int *x, int *y )
{
    OBJECT  *o=object;
    IMAGE   *i=o->toon->img+o->idx;

    switch( SyringeBase )
    {
        case 0:    /*  Points to top left  */
          *x = MouseX;
          *y = MouseY;
          break;
        case 5:    /*  Points to top right  */
          *x = MouseX - i->w + 1;
          *y = MouseY;
          break;
        case 10:   /*  Points to bottom right  */
          *x = MouseX - i->w + 1;
          *y = MouseY - i->h + 1;
          break;
        default:   /*  Points to bottom left  */
          *x = MouseX;
          *y = MouseY - i->h + 1;
    }

    return( ACTIVE_OBJECT );
}

/*========================[ MORPHING Functions ]=============================*/

int Beam_Morph( void *object, int *idx )
{
    BEAM   *b=Cfg.beams + ((OBJECT *)object)->pri - BEAM_TOON_BASE_PRI;

    b->frame += (b->vx<0) ? -1 : 1;
    if ( b->frame<0 ) b->frame=NUM_OF_BEAMS-1; else if ( b->frame>=NUM_OF_BEAMS ) b->frame=0;

    *idx = b->frame;

    return( ACTIVE_OBJECT );
}

int Counter_Morph( void *object, int *idx )
{
    int     i=((OBJECT *)object)->pri - COUNTER_TOON_BASE_PRI;

    if ( (*idx=Cfg.nuclei[i].cframe)==0 )
    {
        if ( Lev->time_meltdown ) Meltdown=TIME_MELTDOWN;
    }

    return( ACTIVE_OBJECT );
}

int PowerUp_Morph( void *object, int *idx )
{
    if ( (++Power_Up_Delay) >= POWER_UP_FRAME_DELAY )
    {
        Power_Up_Delay = 0;
        if ( (*idx)>=8 )
        {
            if ( (++(*idx)) >= 16 ) *idx=8;
        }
        else
        {
            if ( (++(*idx)) >= 8 ) *idx=0;
        }
    }

    return( ACTIVE_OBJECT );
}

int Rogue_Morph( void *object, int *idx )
{
    PARTICLE   *p = Cfg.rogues + ((OBJECT *)object)->pri - ROGUE_TOON_BASE_PRI;

    if ( p->time==0 )
    {
        p->rogue = FALSE;
        return( DELETE_OBJECT );
    }

    if ( (++(p->delay))>=ROGUE_FRAME_DELAY )
    {
        p->delay=0;
        if ( (++(p->frame))>=NUM_OF_ROGUE_PARTICLES ) p->frame=0;
        *idx = p->frame;
    }

    return( ACTIVE_OBJECT );
}

int Shield_Morph( void *object, int *idx )
{
    SHIELD   *s=Cfg.shields + ((OBJECT *)object)->pri - SHIELD_TOON_BASE_PRI;

    if ( !s->time )
    {
        s->active = FALSE;
        return( DELETE_OBJECT );
    }

    if ( s->frame < NUM_OF_SHIELDS-2 )
    {
        if ( (++(s->reps)) >= SHIELD_GROWTH_REPS )
        {
            s->reps  = 0;
            (s->frame)++;
            s->rx    = Shield_Icons[s->frame].w>>1;
            s->ry    = Shield_Icons[s->frame].h>>1;
        }
    }
    else
    {
        if ( s->reps++ )
        {
            s->frame^=0x01;
            s->reps  =0;
        }
    }

    *idx = s->frame;

    return( ACTIVE_OBJECT );
}

int Syringe_Morph( void *object, int *idx )
{
    static char   delay=0;
    int           x1,y1,x2,y2;

    if ( SyringeDir != 0 )
    {
        if ( delay--==0 )
        {
            delay = 1;
            if ( SyringeOffset+SyringeDir < 0 ) SyringeDir=0; else
              if ( SyringeOffset+SyringeDir >= SYRINGE_FRAMES ) SyringeDir=-SyringeDir;
            SyringeOffset += SyringeDir;
        }
    }

    switch( SyringeBase )
    {
        case 0:
          x2 = (x1=MouseX) + SYRINGE_THRESHOLD - 1;
          y2 = (y1=MouseY) + SYRINGE_THRESHOLD - 1;
          break;
        case 5:
          x1 = (x2=MouseX) - SYRINGE_THRESHOLD + 1;
          y2 = (y1=MouseY) + SYRINGE_THRESHOLD - 1;
          break;
        case 10:
          x1 = (x2=MouseX) - SYRINGE_THRESHOLD + 1;
          y1 = (y2=MouseY) - SYRINGE_THRESHOLD + 1;
          break;
        default:
          x2 = (x1=MouseX) + SYRINGE_THRESHOLD - 1;
          y1 = (y2=MouseY) - SYRINGE_THRESHOLD + 1;
    }

    if ( x1<VX_MIN || y1<VY_MIN || x2>VX_MAX || y2>VY_MAX )
    {
        if ( MouseY < VY_MAX-SYRINGE_THRESHOLD )
          SyringeBase = (MouseX > VX_MIN+SYRINGE_THRESHOLD) ? 5 : 0;
        else
          SyringeBase = (MouseX > VX_MIN+SYRINGE_THRESHOLD) ? 10 : 15;
    }

    *idx = SyringeBase+SyringeOffset;

    return( ACTIVE_OBJECT );
}

/*==========================[ End Of Source File ]===========================*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -