Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Possible to show only a part of a sprite (uv-scrolling?)

Author
Message
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 7th Jan 2014 12:55 Edited at: 7th Jan 2014 13:01
Hi all,

I recently started to code a minimap for my game. The code below generates a map using a single sprite that is colored according to the 'tile-class' it should display. Once done, the generated image is copied to a new sprite that is displayed on the users' screen. So far so good, but I was wondering:

Can I zoom the sprite to show only a part of it (the players range of sight) and then scroll it when the user moves? I know there are UV-scaling and scrolling commands in AppGameKit for sprites, but I haven't found examples that allow a user only to see a part of the sprite.

Anyway, for those interested in the minimap-generation thing, here's the code (it requires a media-file with the map, so I've also attached a .zip containing everything):

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Jan 2014 13:59
setSpriteScissor

oct(31) = dec(25)
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 7th Jan 2014 16:03
Quote: "
setSpriteScissor
"


Thank you, I'll look into that!
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 10th Jan 2014 20:24 Edited at: 11th Jan 2014 07:51
I managed to get this working with the SetSpriteScissor-tip... thanks again! I'm posting the code here for 'posterity's' sake.



What it does:
- generates a large sprite with an image of a map
- finds a valid position for a player on the map
- crops the map according to the position of the player (e.g. the clipped sprite is moved, so only the part around the player is visible).

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Jan 2014 21:20
Just for the sake of it, if you wanted to do this by adjusting the UV coords: http://forum.thegamecreators.com/?m=forum_view&t=207872&b=6

Login to post a reply

Server time is: 2024-11-25 02:41:29
Your offset time is: 2024-11-25 02:41:29