Homebrew Scrolling + Collision

sleight

Well-Known Member
OP
Newcomer
Joined
Nov 23, 2008
Messages
73
Trophies
0
XP
63
Country
Gambia, The
EDIT: Omg I don't understand anything atm.. It worked after i REMOVED the collision map...


w/e.. lock this thread pls







Got some problems with the collision map and scrolling..


http://www.megaupload.com/?d=H21W6LYN

I 've tried to add vertical scrolling but didn't work..
also have no idea how to change the starting position



CODE#include
#include "gfx/all_gfx.c"
#include "gfx/all_gfx.h"
#include "loosey.h"


#define norm_fix(x)ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ((x)8)
#define fix_mult(x,y)ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ(((x)*(y))>>8)
#define ratio_fix(x,y)ÂÂÂÂÂÂÂÂÂÂ ((256*(x))/(y))
#define fixed_fraction(x)ÂÂÂÂÂÂÂÂ((x)&&0xff)



typedef struct{
ÂÂ s8 x, y, flipx;
}pointinfo;

typedef struct{
ÂÂ pointinfo left, right, up, down;
ÂÂ u8 flipped;
}hitboxinfo;
typedef struct{
ÂÂÂÂs32 x, y;
ÂÂÂÂ//s32 vy;ÂÂ// benutzt fürs springen
ÂÂÂÂs32 scrollx;
ÂÂÂÂs32 scrolly;
ÂÂÂÂu8 sprite; //the sprite number
ÂÂÂÂu8 jumping;
ÂÂÂÂhitboxinfo hitbox;
ÂÂÂÂu32 speed;
} rintype;
rintype rin;
#define GRAVITY 0
#define Rin_SPEED 512

void MoveRin(void);
void scroll();
void CheckCollisions(void);
u8 GetTile(s16 x, s16 y);
u8 LeftCollision(void);
u8 RightCollision(void);
u8 DownCollision(void);
u8 tilecollsion(s32,s32,u8,u8);
u8 allcollision();
u8 collision(s32,s32,u8,u8);
u8 getsprite();



void newgame();
void fadedark();
void fadenorm();


u8 sprite[128];

int main(int argc, char ** argv)
{
ÂÂÂÂÂÂ PA_Init();
ÂÂÂÂÂÂ PA_InitVBL();
ÂÂÂÂÂÂ PA_InitSound();
ÂÂÂÂÂÂ PA_InitText(0,0);
ÂÂÂÂÂÂ PA_InitText(1,0);
ÂÂÂÂÂÂ s32 i;
ÂÂÂÂÂÂ fadedark();
ÂÂÂÂÂÂ for(i = 0; i < 32; i++) PA_WaitForVBL();
ÂÂÂÂÂÂ PA_LoadTiledBg(1,3,nintendo);
ÂÂÂÂÂÂ PA_LoadTiledBg(0,3,nintendo);
ÂÂÂÂÂÂ fadenorm();
ÂÂÂÂÂÂ for(i = 0; i < 32; i++) PA_WaitForVBL();
ÂÂÂÂÂÂ fadedark();
ÂÂÂÂÂÂ PA_LoadTiledBg(1, 3, title_top);
ÂÂÂÂÂÂ PA_LoadTiledBg(0,3,title_bottom);
ÂÂÂÂÂÂ PA_LoadSpritePal(0,0,(void*)title_Pal);
ÂÂÂÂÂÂ PA_CreateSprite(0, 1,(void*)title_load_Sprite, OBJ_SIZE_64X32,1,0,166, 90);
ÂÂÂÂÂÂ PA_CreateSprite(0, 0,(void*)title_newgame_Sprite,OBJ_SIZE_64X32,1,0,32, 90);
ÂÂÂÂÂÂ fadenorm();
ÂÂÂÂÂÂ PA_PlaySimpleSound(0, loosey);


ÂÂÂÂÂÂ while (1)
ÂÂÂÂÂÂ {
ÂÂÂÂÂÂ if (PA_SpriteTouched(0)) newgame();

ÂÂÂÂÂÂ PA_WaitForVBL();
ÂÂÂÂÂÂ }

ÂÂÂÂÂÂ return 0;
ÂÂÂÂÂÂ }


void fadedark(){
ÂÂÂÂÂÂs32 fade;
ÂÂÂÂÂÂfor (fade = 0; fade >= -31; fade--) {
ÂÂÂÂÂÂPA_SetBrightness(1, fade);
ÂÂÂÂÂÂPA_SetBrightness(0, fade);
ÂÂÂÂÂÂPA_WaitForVBL();
ÂÂÂÂÂÂPA_WaitForVBL();}
ÂÂÂÂÂÂ}

void fadenorm(){
ÂÂÂÂÂÂs32 fade;
ÂÂÂÂÂÂfor (fade = -31; fade 160) && (fix_norm(rin.x) < 512-128)){ // Scroll more...
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂrin.scrollx = rin.x - norm_fix(160);
ÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂelse if ((((rin.x-rin.scrollx)>>8) < 64) && ((rin.x>>8) > 64)){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂrin.scrollx = rin.x - norm_fix(64);
ÂÂÂÂÂÂÂÂ}

ÂÂÂÂÂÂÂÂif (((fix_norm(rin.y-rin.scrolly)) > 160) && (fix_norm(rin.y) < 512-128)){ // Scroll more...
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂrin.scrolly = rin.y - norm_fix(160);
ÂÂÂÂÂÂÂÂ}
ÂÂÂÂÂÂÂÂelse if ((((rin.y-rin.scrolly)>>8) < 64) && ((rin.y>>8) > 64)){
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂrin.scrolly = rin.y - norm_fix(64);
ÂÂÂÂÂÂÂÂ}


ÂÂÂÂÂÂÂÂPA_ParallaxScrollXY(0, fix_norm(rin.scrollx),fix_norm(rin.scrolly));
ÂÂÂÂÂÂÂÂ//move player
ÂÂÂÂÂÂÂÂPA_SetSpriteXY(0, rin.sprite, fix_norm(rin.x-rin.scrollx), fix_norm(rin.y-rin.scrolly));


}







u8 GetTile(s16 x, s16 y){
ÂÂÂÂif (x < 0 || x > 460) return 1; // Gibt 1 zurück wenn das Sprite sich horizontal aus der Karte bewegt hat (Kollision!)
ÂÂÂÂreturn lumine_collision_Map[((y>>3)*64) + (x>>3)];
}

u8 TileCollision(pointinfo point, u8 flipped){
ÂÂ return (GetTile(fix_norm(rin.x)+point.x + (flipped*point.flipx), fix_norm(rin.y)+point.y));
}


u8 anycollision(u8 tile, hitboxinfo hitbox){
ÂÂ if(TileCollision(hitbox.left, hitbox.flipped)==tile)return 1;
ÂÂ if(TileCollision(hitbox.right, hitbox.flipped)==tile)return 2;
ÂÂ if(TileCollision(hitbox.up, hitbox.flipped)==tile)return 3;
ÂÂ if(TileCollision(hitbox.down, hitbox.flipped)==tile)return 4;
ÂÂ else return 0;
}

u8 collision(s32 x2, s32 y2, u8 h2, u8 w2){
ÂÂ if (ÂÂÂÂÂÂÂÂ(fix_norm(rin.x)>x2+w2) || (fix_norm(rin.x)+30y2+h2) || (fix_norm(rin.y)+30
 

You may also like...

General chit-chat
Help Users
    AncientBoi @ AncientBoi: hmmmm.. someone might have hacked into your account :unsure: