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
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • BigOnYa @ BigOnYa:
    Did you pay your power bill? Or give all yo money to my wife, again.
  • K3Nv2 @ K3Nv2:
    Oh good the estimated time is the same exact time they just said
    +1
  • BigOnYa @ BigOnYa:
    Load up your pc and monitor, and head to a McDonalds dining room, they have free WiFi
  • K3Nv2 @ K3Nv2:
    Sir please watch your porn in the bathroom
    +2
  • BigOnYa @ BigOnYa:
    No sir we can not sell you anymore apple pies, after what you did with the last one.
  • K3Nv2 @ K3Nv2:
    We ran out
  • HiradeGirl @ HiradeGirl:
    for your life
    +1
  • K3Nv2 @ K3Nv2:
    My life has no value my fat ass is staying right here
  • K3Nv2 @ K3Nv2:
    Nearly 4 hours without power :(
  • Veho @ Veho:
    SO POWERLESS
  • K3Nv2 @ K3Nv2:
    Tell Kanye I need power
  • DinohScene @ DinohScene:
    Better start running in your hamster wheel
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Meth addicts on a treadmill connected to a generator "Unlimited POWER!!!'
  • Veho @ Veho:
    Before or after a hit?
  • Veho @ Veho:
    Do you dangle a baggie in front of them, like a carrot?
  • The Real Jdbye @ The Real Jdbye:
    they're the same thing
  • The Real Jdbye @ The Real Jdbye:
    i like that idea
  • Veho @ Veho:
    What's the same thing?
  • The Real Jdbye @ The Real Jdbye:
    before or after a hit
  • Veho @ Veho:
    Nah, a hit gives them mad meth powers, but makes them more difficult to control.
  • Veho @ Veho:
    Before a hit they're like zombies, persistent but slow.
  • Veho @ Veho:
    It's a tradeoff.
    Veho @ Veho: It's a tradeoff.