Serguei2 Posted August 3, 2019 Share Posted August 3, 2019 Is there a way for sprites to detect tiles? Quote Link to comment Share on other sites More sharing options...
Kiwi Posted August 3, 2019 Share Posted August 3, 2019 I use software solution. For top down RPG style. I poll the name table. So the code is... if(joypad_1&UP){playerp=2*16; if (walk==0){walk=15;} y=(playery+8)/8; x=(playerx+8)/8; TileID = get_char(x,y); if(TileID>=192){playery--;} } if(joypad_1&RIGHT){playerp=1*16; if (walk==0){walk=15;} y=(playery+12)/8; x=(playerx+12)/8; TileID = get_char(x,y); if(TileID>=192){playerx++;} } if(joypad_1&DOWN){playerp=0*16; if (walk==0){walk=15;} y=(playery+16)/8; x=(playerx+8)/8; TileID = get_char(x,y); if(TileID>=192){playery++;} } if(joypad_1&LEFT){playerp=3*16; if (walk==0){walk=15;} y=(playery+12)/8; x=(playerx+4)/8; TileID = get_char(x,y); if(TileID>=192){playerx--;} } "TileID>=192" are the tiles that are impassable. If you're using ICVGM. The last 1/4 tiles are solid. This would be your character's center, y=(playery+12)/8; x=(playerx+8)/8; TileID = get_char(x,y); If you want to have a hazardous tiles like lava or spikes, You can do, if(TileID==191){OuchySpike();}. Keep in mind if you're going below the screen, it'll pick up the sprite table data and act on it. So adding if restriction is recommended. 1 1 Quote Link to comment Share on other sites More sharing options...
Serguei2 Posted August 5, 2019 Author Share Posted August 5, 2019 Thanks Kiwi. It works. I noted "if (walk==0){walk=15;}" was not necessary. I remove them from the code and the program still works. Quote Link to comment Share on other sites More sharing options...
Kiwi Posted August 5, 2019 Share Posted August 5, 2019 2 hours ago, Serguei2 said: Thanks Kiwi. It works. I noted "if (walk==0){walk=15;}" was not necessary. I remove them from the code and the program still works. Yeah, that code wasn't necessary. I pulled it out from my New Years Beach Clean Up game since it is a top down game like the Venture type game you're making. It is to reset the walk countdown to change the sprite image to his hopping walk state to his standing state. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.