Page 3 of 4

Re: Project - Mega Dracula - Help / Updates

Posted: Fri Sep 04, 2015 11:37 pm
by djcouchycouch
Check your declarations. Do they have the same names as in the resource file? Are they the correct type?

Re: Project - Mega Dracula - Help / Updates

Posted: Sat Sep 05, 2015 12:03 am
by matteus
Yup all work normal it's only since I tried to pass them to a function did they not work they not work

Code: Select all

void animateEnemy(Sprite headSprite, Sprite bodySprite)
That should work shouldn't it ???

Re: Project - Mega Dracula - Help / Updates

Posted: Sat Sep 05, 2015 12:08 am
by djcouchycouch
Oh I just noticed. The function parameters are sprites when you need sprite definitions.

And you should pass them as pointers too.

Re: Project - Mega Dracula - Help / Updates

Posted: Sun Sep 06, 2015 9:44 am
by matteus
Do you know how I'd play a sprite once forwards and then in reverse?

I've an 8 frame sprite and rather than use double the amount of frames I figured I could probably reverse the animation but I can't see a function to do it?

Re: Project - Mega Dracula - Help / Updates

Posted: Sun Sep 06, 2015 10:56 am
by djcouchycouch
You need a counter per animated object that tells which frame to show. If you want the animation to go forward then you increment the counter. If the animation goes backward then you decrement the counter.

I don't think there's a function to do it. You'll have to manage that on your own.

Re: Project - Mega Dracula - Help / Updates

Posted: Mon Sep 07, 2015 9:51 am
by matteus
I'm trying to do a fade using:

Code: Select all

void VDP_fadeOut(u16 fromcol, u16 tocol, u16 numframe, u8 async);
and

Code: Select all

u16 VDP_isDoingFade();
My code however doesn't work!

Code: Select all

if (Dead == 0) {
	VDP_fadeOut(32, 47, 20, TRUE);
        if (VDP_isDoingFade == FALSE) {
		SPR_clear();
                drawnSprite = 0;
		SubStageInt = 2;
	}
}

Re: Project - Mega Dracula - Help / Updates

Posted: Mon Sep 07, 2015 12:25 pm
by Stef
I don't understand what you expect from this piece of code :

Code: Select all

if (Dead == 0) {
   VDP_fadeOut(32, 47, 20, TRUE);
        if (VDP_isDoingFade == FALSE) {
      SPR_clear();
                drawnSprite = 0;
      SubStageInt = 2;
   }
}
Actually VDP_isDoingFade() will always return TRUE as you just started a asynchronous fade process just before.

Re: Project - Mega Dracula - Help / Updates

Posted: Mon Sep 07, 2015 1:44 pm
by matteus
So if it was set to false would that code work? I thought calling VDP_isDoingFade would tell me when the fade is finished?

Re: Project - Mega Dracula - Help / Updates

Posted: Mon Sep 07, 2015 2:17 pm
by Moon-Watcher

Code: Select all

if (Dead == 0) {
	VDP_fadeOut(32, 47, 20, TRUE);
        if (VDP_isDoingFade == FALSE) {
		SPR_clear();
                drawnSprite = 0;
		SubStageInt = 2;
	}
}

Code: Select all

if (Dead == 0) {
	VDP_fadeOut(32, 47, 20, FALSE);
	SPR_clear();
	drawnSprite = 0;
	SubStageInt = 2;
}
You mean? Sync fade locks execution until it's finished

Re: Project - Mega Dracula - Help / Updates

Posted: Mon Sep 07, 2015 4:43 pm
by Stef
Exactly... You should not use async fade if you want to wait for fade execution before doing something else ;)

Re: Project - Mega Dracula - Help / Updates

Posted: Mon Sep 07, 2015 11:15 pm
by matteus
question the random function is a u16 but all the maths functions are fix16 :/ So how do I do maths with a random number? Is there a way to convert the u16 to fix16? I can only see Int to fix16.

Re: Project - Mega Dracula - Help / Updates

Posted: Tue Sep 08, 2015 10:41 am
by Stef
You can just use the random method to produce a random fix16 number. they have the same size so that doesn't make any difference ;)

Re: Project - Mega Dracula - Help / Updates

Posted: Tue Sep 08, 2015 4:59 pm
by matteus
Noticing a few bugs with sprites not sure if it's to do with how I call and play them.

Anyhow here is an updated video of my progress:

https://youtu.be/RXl1tiM3M0w

Re: Project - Mega Dracula - Help / Updates

Posted: Tue Sep 08, 2015 9:33 pm
by matteus
Stef does strclr clear chars completely? The following example strclr(tempTextline) doesn't seem to be working?

Code: Select all

#include <genesis.h>

struct ScreenMessages
{
    char line1[36];
    char line2[36];
    char line3[36];
};

u16 displayOnScreenMessages(struct ScreenMessages Messages);

u16 increment = 0;
u16 ind;
u16 stage = 0;
u16 textStage = 0;
u16 timerSeconds = 500;
u16 timer = 0;
char tempTextline[36];
struct ScreenMessages Messages;

int main()
{
    // disable interrupt when accessing VDP
    SYS_disableInts();

    // initialization
    VDP_setScreenWidth320();

    // VDP process done, we can re enable interrupts
    SYS_enableInts();

    ind = TILE_USERINDEX;

    while(TRUE)
    {
        switch (stage) {
        case 0:
            strcpy(Messages.line1, "1 2 3 4 5 6 7 8 9 10 11 12 13 15 16");
            strcpy(Messages.line2, "17 18 19 20 21 22");
            strcpy(Messages.line3, "23 24 25");
            stage++;
            break;
        case 1:
            if (displayOnScreenMessages(Messages) == TRUE) {
                stage++;
            }
            break;
        case 2:
            VDP_drawText("Complete!", 14, 10);
            stage++;
            break;
        }
    }
    return 0;
}

u16 displayOnScreenMessages(struct ScreenMessages Messages) {
    char character[0];
    u16 complete = FALSE;

    switch(textStage) {
    case 0:
        increment = 0;
        timer = 0;
        strclr(tempTextline);
        strcpy(tempTextline, Messages.line1);
        textStage++;
    break;
    case 1:
        if (timer == 0) {
            if (increment <= sizeof(tempTextline)) {
                character[0] = tempTextline[increment];
                VDP_drawText(character, 2+increment, 23);
                strclr(character);
                timer = timerSeconds;
                VDP_drawText(tempTextline, 2, 2);
                increment++;
            } else {
                textStage++;
            }
        } else if (timer > 0) {
            timer--;
        }
    break;
    case 2:
        increment = 0;
        timer = 0;
        strclr(tempTextline);
        strcpy(tempTextline, Messages.line2);
        textStage++;
    break;
    case 3:
        if (timer == 0) {
            if (increment <= sizeof(tempTextline)) {
                character[0] = tempTextline[increment];
                VDP_drawText(character, 2+increment, 24);
                strclr(character);
                timer = timerSeconds;
                VDP_drawText(tempTextline, 2, 2);
                increment++;
            } else {
                textStage++;
            }
        } else if (timer > 0) {
            timer--;
        }
    break;
    case 4:
        increment = 0;
        timer = 0;
        strclr(tempTextline);
        strcpy(tempTextline, Messages.line3);
        textStage++;
    break;
    case 5:
        if (timer == 0) {
            if (increment <= sizeof(tempTextline)) {
                character[0] = tempTextline[increment];
                VDP_drawText(character, 2+increment, 25);
                strclr(character);
                timer = timerSeconds;
                VDP_drawText(tempTextline, 2, 2);
                increment++;
            } else {
                textStage = 0;
                complete = TRUE;
            }
        } else if (timer > 0) {
            timer--;
        }
    break;
    }
    return complete;
}

Re: Project - Mega Dracula - Help / Updates

Posted: Wed Sep 09, 2015 7:55 pm
by matteus
IS this how to enable a sprite?

Code: Select all

               
VDP_setPalette(PAL3, ghoul_sprite.palette->data);
SPR_initSprite(&sprites[0], (SpriteDefinition*)&ghoul_sprite, EnemySpriteXInt, EnemySpriteYInt+40, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));

Also I'm using this code to write on screen text however I'm getting artifacts it only seems to happen after I load and animate a sprite.

Code: Select all

u16 writeOnScreenMessage(char message[], u16 messageRow) {
    u16 completeOnScreenMessage = FALSE;
    char character[0];
    u16 stringLength = strlen(message) - 1;
    if (timer == 0) {
        if (increment <= stringLength) {
            character[0] = message[increment];
            VDP_drawText(character, 2+increment, messageRow);
            strclr(character);
            timer = timerSeconds;
            increment++;
            completeOnScreenMessage = FALSE;
        } else {
            timer = 0;
            increment = 0;
            completeOnScreenMessage = TRUE;
        }
    } else if (timer > 0) {
        timer--;
        completeOnScreenMessage = FALSE;
    }
    return completeOnScreenMessage;
}
In the image notice the weird L shaped pixels at the end!

Image