Project - Mega Dracula - Help / Updates

SGDK only sub forum

Moderator: Stef

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Re: Project - Mega Dracula - Help / Updates

Post by djcouchycouch » Fri Sep 04, 2015 11:37 pm

Check your declarations. Do they have the same names as in the resource file? Are they the correct type?

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Sat Sep 05, 2015 12:03 am

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 ???

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Re: Project - Mega Dracula - Help / Updates

Post by djcouchycouch » Sat Sep 05, 2015 12:08 am

Oh I just noticed. The function parameters are sprites when you need sprite definitions.

And you should pass them as pointers too.

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Sun Sep 06, 2015 9:44 am

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?

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Re: Project - Mega Dracula - Help / Updates

Post by djcouchycouch » Sun Sep 06, 2015 10:56 am

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.

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Mon Sep 07, 2015 9:51 am

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;
	}
}

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Project - Mega Dracula - Help / Updates

Post by Stef » Mon Sep 07, 2015 12:25 pm

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.

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Mon Sep 07, 2015 1:44 pm

So if it was set to false would that code work? I thought calling VDP_isDoingFade would tell me when the fade is finished?

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Re: Project - Mega Dracula - Help / Updates

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

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

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Project - Mega Dracula - Help / Updates

Post by Stef » Mon Sep 07, 2015 4:43 pm

Exactly... You should not use async fade if you want to wait for fade execution before doing something else ;)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Mon Sep 07, 2015 11:15 pm

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.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Project - Mega Dracula - Help / Updates

Post by Stef » Tue Sep 08, 2015 10:41 am

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 ;)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Tue Sep 08, 2015 4:59 pm

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

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Tue Sep 08, 2015 9:33 pm

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;
}

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: Project - Mega Dracula - Help / Updates

Post by matteus » Wed Sep 09, 2015 7:55 pm

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

Post Reply