Homebrew Scrolling + Collision


Well-Known Member
Nov 23, 2008
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..


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

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

typedef struct{
ÂÂ pointinfo left, right, up, down;
ÂÂ u8 flipped;
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_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();


ÂÂÂÂÂÂ return 0;

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

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
  • Psionic Roshambo @ Psionic Roshambo:
    Wake up in your bed with a sore ass and believe whatever you want to believe!
  • SylverReZ @ SylverReZ:
  • K3Nv2 @ K3Nv2:
    If I watch enough lesbian porn they might learn from me
  • Veho @ Veho:
    Lesbi real, they probably won't.
  • BakerMan @ BakerMan:
    how's the weather for yall today?
  • BakerMan @ BakerMan:
    i'll keep it a buck with you guys, it's stormy as hell over here, and it's supposed to be like that all day
  • Veho @ Veho:
    Raining here too.
  • Veho @ Veho:
    At least it broke the heat wave, that was rough.
  • AncientBoi @ AncientBoi:
    ⛅ Sun fighting off dark clouds :( here
  • AncientBoi @ AncientBoi:
    ☀️ usually already shining in my bedroom here at 6:35 am, but.. :unsure::unsure::unsure: idk
  • rsx @ rsx:
    Hot AF the last few days here in southern california
  • jknx @ jknx:
    same here in jersey
  • S @ salazarcosplay:
    Did you play golden eye on n64 when it came out back in the n64 days
  • S @ salazarcosplay:
    did you play halo in original xbox?
  • Sicklyboy @ Sicklyboy:
    I did!
  • S @ salazarcosplay:
    @Sicklyboy what was it like
  • Sicklyboy @ Sicklyboy:
    Incredible. I was 10-11 when I first played. No school, no responsibilities, no online multiplayer, no HDMI, no 1080p, no day 1 patches. Pop in the disk, hope that your Xbox's disk drive decides to cooperate today, and just play for hours and hours
  • Sicklyboy @ Sicklyboy:
    ANd that's not even taking into account all of the issues that cropped up in the Gearbox Halo PC port, and how those issues propagated to all of the subsequent rereleases and remasters
  • Psionic Roshambo @ Psionic Roshambo:
    I had N64 and PS1 and PC at the time Golden Eye came out was a great time to be alive lol
    Psionic Roshambo @ Psionic Roshambo: I had N64 and PS1 and PC at the time Golden Eye came out was a great time to be alive lol