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
  • K3Nv2
  • BakerMan
    I rather enjoy a life of taking it easy. I haven't reached that life yet though.
  • Veho @ Veho:
    Do you dangle a baggie in front of them, like a carrot?
    +1
  • The Real Jdbye @ The Real Jdbye:
    they're the same thing
    +1
  • The Real Jdbye @ The Real Jdbye:
    i like that idea
    +1
  • Veho @ Veho:
    What's the same thing?
    +1
  • The Real Jdbye @ The Real Jdbye:
    before or after a hit
    +1
  • Veho @ Veho:
    Nah, a hit gives them mad meth powers, but makes them more difficult to control.
    +1
  • Veho @ Veho:
    Before a hit they're like zombies, persistent but slow.
    +1
  • Veho @ Veho:
    It's a tradeoff.
    +1
  • The Real Jdbye @ The Real Jdbye:
    no i mean, before a hit is after the previous hit
    +1
  • The Real Jdbye @ The Real Jdbye:
    if you keep them well enough fed, it's the same thing
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    By the power of Florida Man, I have the power!!! *Lifts up meth pipe* Meth Man!!! lol
  • BakerMan @ BakerMan:
    Guys, I just learned my little brother is in the hospital because he had a seizure last night.
  • cearp @ cearp:
    Sorry to hear that BakerMan
    +2
  • BakerMan @ BakerMan:
    Just found out he's doing alright, doing a lot of complaining too, rightfully so. Who wouldn't complain after having a seizure and being hospitalized?
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Glad he is OK and complaining is cool :)
    +1
  • K3Nv2 @ K3Nv2:
    Yeah been there had that no fun
    +1
  • K3Nv2 @ K3Nv2:
    They'll give him sleep studies eegs and possibly one week hospital stay
    +1
  • BakerMan @ BakerMan:
    I hope it's not a week.
  • K3Nv2 @ K3Nv2:
    It's standard so doctors can get a idea about what's going on
  • BakerMan @ BakerMan:
    understood
  • BakerMan @ BakerMan:
    well, i'm glad he seems to be doing fine, and ig i'm going to start spewing goofy shit again
  • BakerMan @ BakerMan:
    Update: Turns out he's epileptic
  • K3Nv2 @ K3Nv2:
    Get a 2nd opinion run mris etc they told me that also
    K3Nv2 @ K3Nv2: Get a 2nd opinion run mris etc they told me that also