Jump to content
Sign in to follow this  
Bochum_Boy

Sprite Glitch

Recommended Posts

Dear all,

 

as I am working on a small Donkey Kong like game for the Lynx, I face a glitch by recent sprite addins:

 

post-47956-0-21697200-1535113460.png

 

The sprites showing the platforms are stretched and extended. If I use the sprite outside my project (in a test project) the glitches disappear. Did I run out of storage?

#include <lynx.h>
#include <tgi.h>
#include <joystick.h>
#include <6502.h>
#include <stdlib.h>


//Bear Sprite

unsigned char bb_w1[] = {
	0xd,   0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xbb, 0x0, 0x0, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x0, 0xb, 0xb0, 0x0, 0xbb, 0x55, 0xbb, 0x0, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0xb, 0xb5, 0x5b, 0xbb, 0xbb, 0xbb, 0x55, 0x0, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x5, 0x55, 0x5b, 0xb8, 0x88, 0x88, 0x88, 0x0, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x0, 0xb, 0xb8, 0x88, 0x88, 0x88, 0xbb, 0x0, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x0, 0xb, 0xb8, 0x8b, 0xb8, 0x88, 0x55, 0xaa, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x0, 0xb, 0xb8, 0x88, 0x85, 0x55, 0x55, 0x55, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x0, 0xb, 0xbb, 0xb8, 0x85, 0x55, 0x55, 0x55, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x0, 0x88, 0x88, 0xbb, 0xb5, 0x55, 0x55, 0x0, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x88, 0x88, 0x88, 0x8b, 0xbb, 0xbb, 0xb8, 0x0, 0x0, 0x0, 0x0, 
	0xd,   0x0, 0x88, 0x8b, 0xbb, 0xbb, 0xbb, 0xbb, 0xc8, 0x80, 0x0, 0x0, 0x0, 
	0xd,   0xb, 0x88, 0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aa, 0x99, 0x9a, 0xaa, 0xa9, 0x99, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x99, 0xaa, 0xa9, 0xa9, 
	0x1a,   0xbb, 0xb5, 0x5b, 0xbb, 0xbb, 0xb6, 0xbb, 0x66, 0x66, 0x6b, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 
	0x1a,   0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0x66, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 
	};






    
//Arrays of sprites
    
char* bb_spritedata[] =
{
	bb_w0, bb_w1,
    bb_t0, bb_t1,
    bb_j0, bb_j1
};

char* hive_spritedata[] =
{
    hive_0,hive_1,hive_2
};

//Struct of Bear
typedef struct {
  char depository;
  SCB_REHVST_PAL sprite;
  unsigned char run_index;
  unsigned char lives;
  signed int crystals;
  unsigned char jump_index;
} sprite_t;

//Struct of Soil
typedef struct {
  char depository;
  SCB_REHVST_PAL sprite;
  signed char index;
} soil_t;

//Struct of Crystal
typedef struct {
  char depository;
  SCB_REHVST_PAL sprite;
  signed char hvel;
  signed char vvel;
} ballsprite_t;

//Struct of Hive
typedef struct {
  char depository;
  SCB_REHVST_PAL sprite;
  signed char points;
  unsigned char dead;
} hivesprite_t;

//Struct of Enemy
typedef struct {
  char depository;
  SCB_REHVST_PAL sprite;
  signed char hvel;
  signed char vvel;
  signed char isDead;
} enemy_t;

//Spritepacks
sprite_t BBear = {
    0x0,
    {
    BPP_4 | TYPE_NORMAL,REHVST | LITERAL,
    0x02,
	0,
    bb_w0,
    5, 75,
    0x100, 0x100,
    0x000, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
},0,4,5,0
};

soil_t SSoil_Bottom = {0x0,
    {
    BPP_4 | TYPE_BACKGROUND ,REHVST | LITERAL,
    0x05,
	0,
    soil_0,
    0, 99,
    0x400, 0x100,
    0x100, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
    },0
};

soil_t SSoil_Level3 = {0x0,
    {
    BPP_4 | TYPE_BACKGROUND ,REHVST | LITERAL,
    0x06,
	0,
    soil_0,
    20, 25,
    0x100, 0x100,
    0x000, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
    },3
};


soil_t SSoil_Level3a = {0x0,
    {
    BPP_4 | TYPE_BACKGROUND ,REHVST | LITERAL,
    0x07,
	0,
    soil_0,
    120, 25,
    0x100, 0x100,
    0x000, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
    },3
};

soil_t SSoil_Level1 = {0x0,
    {
    BPP_4 | TYPE_BACKGROUND ,REHVST | LITERAL,
    0x08,
	0,
    soil_0,
    10, 70,
    0x100, 0x100,
    0x000, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
    },1}
;

soil_t SSoil_Level2 = {0x0,
    {
    BPP_4 | TYPE_BACKGROUND ,REHVST | LITERAL,
    0x09,
	0,
    soil_0,
    70, 50,
    0x100, 0x100,
    0x000, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
    },2}
;


ballsprite_t CCrystal = {
    0x0,
    {
    BPP_4 | TYPE_NORMAL,REHVST | LITERAL,
    0x3,
    0,
    crystalBall,
    5, 75,
    0x100, 0x100,
    0x000, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
},5,2,
};



hivesprite_t Hive = {
    0x0,
    {
    BPP_4 | TYPE_NORMAL,REHVST | LITERAL,
    0x02,
    0,
    hive_0,
    100, 75,
    0x100, 0x100,
    0x000, 0x000,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
},50,0
};



//Variables
signed char Run_Index = 0;
signed char Hive_Index = 0;
signed char Bee_Index = 0;

signed char Hive_hasRespawn = 0;

signed int  Score = 0;
signed char hasInit = 0;


unsigned char joy,jump_released,ticks;
unsigned char wait_buttonrelease = 1;


//Variable arrays
int coordinates[] = {0,0,0,0,0};


//Routine for Hive respawning
void respawn_hive(){
    Hive_hasRespawn = 1;
    Hive.points = 50;   
    Hive.sprite.hpos = (rand() & 0xf)*4 + 1;
    Hive.sprite.vpos = (rand() & 0xf)*4 + 1;
    
    while (Hive.sprite.vpos < 25) {
        Hive.sprite.vpos = (rand() & 0xf)*4 + 1;
    }
    
    Hive.dead = 0;
}



//Routine for Input
void read_input(){
    joy = joy_read(JOY_1);
    }



 
//Routine to create level
void draw_level(){
          
   if (hasInit == 0){
   Score = 0;
   hasInit = 1;
   tgi_clear();
   }
   
   //Soil_Sprite
   tgi_sprite(&SSoil_Bottom.sprite);
   tgi_sprite(&SSoil_Level1.sprite);
   tgi_sprite(&SSoil_Level2.sprite);
   tgi_sprite(&SSoil_Level3.sprite);
   tgi_sprite(&SSoil_Level3a.sprite);

}



void main()
{
  //Init
  char buffer[16];
  
  joy_install(&lynx_stdjoy);
  tgi_install(&lynx_160_102_16);
  tgi_init();
  tgi_setcollisiondetection(1);
  CLI();
  
  

  while (1){
    //setpalette(palette);	
    
    
    while (tgi_busy());
    
    tgi_clear();
    
    tgi_setcolor(COLOR_GREEN);
    tgi_outtextxy(0, 0, "WIP");
    
    
    draw_level();
    read_input(); 
   
    
    //Movements
    if (JOY_BTN_RIGHT(joy)) {
        BBear.sprite.hpos += 3;
        BBear.sprite.data = bb_spritedata[Run_Index];
        Run_Index++;
        if (Run_Index > 1) { Run_Index =  0;}
        
        //Turn BBear in case that he faces wrong dicection
        if(BBear.sprite.sprctl0==228){
            BBear.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | LITERAL;
            CCrystal.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | LITERAL;
        }
    }
    
    if (JOY_BTN_LEFT(joy)) {
        BBear.sprite.hpos -= 3;
        BBear.sprite.data = bb_spritedata[Run_Index];
        
        //Turn BBear in case that he faces wrong dicection
        if(BBear.sprite.sprctl0==196){
            BBear.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | HFLIP;
            CCrystal.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | HFLIP;
        }
        Run_Index++;
        if (Run_Index > 1) { Run_Index =  0;}
    }
    
    
    //Jumping
    if (JOY_BTN_UP(joy)) {

        ticks = 2;
        jump_released = 1;
        

        
        switch (BBear.depository) {
            case 8:
                
                BBear.sprite.vpos = 50;
                BBear.sprite.data = bb_spritedata[4];
                break;
            
            case 9:
                BBear.sprite.vpos = 30;
                BBear.sprite.data = bb_spritedata[4];
                break;
                
            case 6:
                
                BBear.sprite.vpos = 8;
                BBear.sprite.data = bb_spritedata[4];
                break;

                
            case 7:    

                BBear.sprite.vpos = 8;
                BBear.sprite.data = bb_spritedata[4];
                break;
       
        }
    }
    
    //Check Falling      
   switch (BBear.depository) {
            case 0:
                
                BBear.sprite.vpos = 75;
                BBear.sprite.data = bb_spritedata[4];
                break;
       
        }
    
    //Finish animation in case that a jump was initiated
    if (jump_released == 1) {
        ticks--;
        if(ticks >= 0){BBear.sprite.data = bb_spritedata[4+ticks];}
        if(ticks==0){
            jump_released = 0;
            BBear.sprite.data = bb_spritedata[0];
            }
    }
    

    //Check if Bear leaves the screen
    if (BBear.sprite.hpos > 160) {
        BBear.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | HFLIP;
        CCrystal.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | HFLIP;
        BBear.sprite.hpos = 160;
    }
    
    if (BBear.sprite.hpos < 0) {
        BBear.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | LITERAL;
        CCrystal.sprite.sprctl0 = BPP_4 | TYPE_NORMAL | LITERAL;
        BBear.sprite.hpos = 0;
    }
        
    //Fire the Crystal
    if (JOY_BTN_FIRE(joy)) {
        BBear.crystals--;
        if(BBear.crystals > 1){
            BBear.sprite.data = bb_spritedata[3];
            CCrystal.sprite.hpos = BBear.sprite.hpos;
            CCrystal.sprite.vpos = BBear.sprite.vpos;
        }
        
        if(BBear.crystals < 1) {
            BBear.crystals = 0;
        }
    }
    
    //Movement of crystal with regard to direction of BBear
    switch (BBear.sprite.sprctl0){
        case 196:
            CCrystal.sprite.hpos  += (CCrystal.hvel);
            break;
            
        case 228:
            CCrystal.sprite.hpos  -= CCrystal.hvel;
            break;
        
        default:
            break;
    }
    
    //Vertical movement regardless direction
    CCrystal.sprite.vpos += CCrystal.vvel;
    
    
    //Animate Hive
    if(Hive_Index <= 2) {
        Hive.sprite.data = hive_spritedata[Hive_Index];
        //Hive_Index++;
        }        
    
    if(Hive_Index > 2) { Hive_Index=0;}
    
    

    
    //Gain Crystals from Hive
    switch (Hive.depository) {
        
        case 2:
            BBear.crystals += 5;
            Hive.points -=5;
            
            if(Hive.points <= 0) {
                Hive.dead = 1;
                Score++;
                Hive_hasRespawn = 0;}
            
            Hive.depository = 0x0;
            
            break;
         default:
            break;
    }
    

    
    if ((BBear.crystals< 5 && Hive_hasRespawn == 0) || (Hive.dead==1) ){
        respawn_hive();
        
    }
    
    

    
    //Draw collidable sprites
    tgi_sprite(&CCrystal.sprite);    
    tgi_sprite(&BBear.sprite);

    
 
    
    if (Hive.points > 0 && Hive.dead==0) {
        tgi_sprite(&Hive.sprite);
    }
    
    
    //Hunt for five hives
    if (Score  == 5) {
        hasInit = 0;
        tgi_outtextxy(40,40,"New!");
    }
 
    //Debugging text
    itoa(BBear.depository, &buffer[0],10);
    tgi_outtextxy(30, 0, buffer);
    
    itoa(BBear.sprite.vpos, &buffer[0],10);
    tgi_outtextxy(100, 0, buffer);
    
    itoa(BBear.sprite.hpos, &buffer[0],10);
    tgi_outtextxy(130, 0, buffer);
    
    tgi_updatedisplay();
    ;
    }
}

Edited by Bochum_Boy

Share this post


Link to post
Share on other sites

Hmm, this is what I suspected. As I am fairly new to C-Development (coming from Python) these buffers are killing me. Do you see a point in my code where I could tweak the problem out?

Share this post


Link to post
Share on other sites

Another possibility is that I can see a pattern (without even looking at your code):

1) The artefacts appear exactly under the platforms

2) They are always the same

 

So it could be for instance that your platform sprite is not properly defined, like it lacks a proper "ending".

Try to replace the platform sprite data with another, just to see if you still have the problem.

Share this post


Link to post
Share on other sites

soil sprite is missing the 0 at the end

That was the problem. Now, it is fixed! Thanks Sage!

 

It seems to be the problem that might occur using TinySprite. Sometimes the ending byte is included, sometimes not.

Edited by Bochum_Boy

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...