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
  • NinStar @ NinStar:
    there is a plugin that display them on the wii u menu, pretty sure it is enabled by default
  • crafthp434 @ crafthp434:
    so like it doesnt exist
  • crafthp434 @ crafthp434:
    yeah
    ?
  • NinStar @ NinStar:
    it doesn't exist, at least not for aroma
  • crafthp434 @ crafthp434:
    ohhhhh
  • NinStar @ NinStar:
    on tiramisu you can access it by opening mii maker
  • crafthp434 @ crafthp434:
    okay
  • NinStar @ NinStar:
    I don't have a wii u anymore to test it myself, but if homebrews are not visible on the wii u menu I think you can press L + R + minus to open the plugin menu, there should be an option called "homebrews on wii u menu" or something similar
  • crafthp434 @ crafthp434:
    nope
  • crafthp434 @ crafthp434:
    it is L+dpad down+ select
  • crafthp434 @ crafthp434:
    but homebrew is appearing in the home menu btw
  • NinStar @ NinStar:
    yes, now I remember it
  • NinStar @ NinStar:
    then it is working, I also don't like that they did this but it is the only option you have if you are using aroma
  • crafthp434 @ crafthp434:
    i just didint know the homebrew launcher didint exist in aroma
  • crafthp434 @ crafthp434:
    thanks btw
  • Xdqwerty @ Xdqwerty:
    Im downloading fallout 3 goty edition
    +1
  • BigOnYa @ BigOnYa:
    I'm downloading more ram for my hamster pc
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    New hamster PC, with anal operation and BT connectivity!
    +1
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, How do I make enemies respawn on gdevelop after
    the player dies?
  • Psionic Roshambo @ Psionic Roshambo:
    Carrying a PC or phone is so old school!
  • Psionic Roshambo @ Psionic Roshambo:
    Squeeze your cheeks twice to answer calls!
  • BigOnYa @ BigOnYa:
    @Xdqwerty you can use a "spawner" function on any object.
    +1
  • BigOnYa @ BigOnYa:
    Or when your player dies, you can say in code, if enemy exists, do nothing, but if enemy does not exist, then create enemy at certain spot. (This would be a pain tho for lots of emeies)
    +1
  • BigOnYa @ BigOnYa:
    Easiest, simple way would be just restart scene, but player would restart from beginning.
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, thx in advance
    Xdqwerty @ Xdqwerty: @BigOnYa, thx in advance