help me please - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

help me please

I am making a game like Final Fantasy 1 in C and need some help.

I am wondering how do I make a delay function that delays for any number of

seconds I choose? and how do I put in sprites into my game.

I am using djgpp and the allegro library.


Comments

  • : I am making a game like Final Fantasy 1 in C and need some help.

    : I am wondering how do I make a delay function that delays for any number of

    : seconds I choose? and how do I put in sprites into my game.

    : I am using djgpp and the allegro library.

    :



    Allegro has its own delay functions, use those.



    As for sprites, load the sprite into a BITMAP structure and blit it to the screen as a sprite.



    -Xotor-


  • : : I am making a game like Final Fantasy 1 in C and need some help.

    : : I am wondering how do I make a delay function that delays for any number of

    : : seconds I choose? and how do I put in sprites into my game.

    : : I am using djgpp and the allegro library.



    For delays, you can use the internal clock



    unsigned short *Clock = (unsigned short *)0x0000046CL; // Clock pointer



    void pause(int T) // Pause for clock ticks

    {

    unsigned short Now = *Clock;

    while (*Clock - Now < T)

    {

    // Do nothing

    }

    }



    Or wait for the vertical retrace



    void vr()

    {

    while ((inp(0x03DA) & 0x08)) {};

    while (!(inp(0x03DA) & 0x08)) {};

    }



    Sprites? Are you asking how to define a sprite

    struct or how to draw a sprite? Sprite struct

    should appear something like this



    typedef struct _Sprite

    {

    int X, Y, W, H;

    unsigned char *Image;

    char Palette[768]; // optional

    int Visible, Life, Power, Speed;

    } Sprite;



    To draw the sprite, load an image file into

    the Image -- don't feel like getting the code

    -- then use a draw bitmap type function



    DrawBitmap(MySprite->Image);


  • However one problem is that the internal clock (I'm assuming PC clock) is too slow for most games.



    But if you're not timer-intesive then it will do just fine.



    -Xotor-



    : : : I am making a game like Final Fantasy 1 in C and need some help.

    : : : I am wondering how do I make a delay function that delays for any number of

    : : : seconds I choose? and how do I put in sprites into my game.

    : : : I am using djgpp and the allegro library.

    :

    : For delays, you can use the internal clock

    :

    : unsigned short *Clock = (unsigned short *)0x0000046CL; // Clock pointer

    :

    : void pause(int T) // Pause for clock ticks

    : {

    : unsigned short Now = *Clock;

    : while (*Clock - Now < T)

    : {

    : // Do nothing

    : }

    : }

    :

    : Or wait for the vertical retrace

    :

    : void vr()

    : {

    : while ((inp(0x03DA) & 0x08)) {};

    : while (!(inp(0x03DA) & 0x08)) {};

    : }

    :

    : Sprites? Are you asking how to define a sprite

    : struct or how to draw a sprite? Sprite struct

    : should appear something like this

    :

    : typedef struct _Sprite

    : {

    : int X, Y, W, H;

    : unsigned char *Image;

    : char Palette[768]; // optional

    : int Visible, Life, Power, Speed;

    : } Sprite;

    :

    : To draw the sprite, load an image file into

    : the Image -- don't feel like getting the code

    : -- then use a draw bitmap type function

    :

    : DrawBitmap(MySprite->Image);

    :






  • how do you draw sprites?


  • how do you draw sprites?



    Allegro defines functions to delay the game and draw images... go figure.


Sign In or Register to comment.