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 / Wrap sprites around screen?

Author
Message
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 23rd Aug 2015 07:50
Is there a way to make a sprite wrap around the screen like in Balloon Fight? That is that when it starts to go outside the screen on one side it immediately appears on the other?

I know that I can check for position by offset for example and change the x-value of the sprite, but that still creates quite a jerky jumping motion.

https://www.youtube.com/watch?v=4JMY2dMnK_E
Hockeykid
DBPro Tool Maker
16
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 23rd Aug 2015 09:20 Edited at: 23rd Aug 2015 09:21
Quote: "That is that when it starts to go outside the screen on one side it immediately appears on the other?"


The easiest way in AppGameKit to wrap a sprite around the screen would be to use duplicates of the sprite that are positioned in negative space and update their movement as you update the sprites movement. One for each direction of the screen. This would mean that you would need a total of 4 sprites for every 1 "wrapping" sprite. Alternatively you could just use 2 sprites and calculate the position offset from the other side.

Here's some sample code for the first method (move with the left and right arrow keys):


Here is some quick sample code I wrote for the second method (move with the left and right arrow keys):




Sean

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Aug 2015 10:25
or maybe with DrawSprite and a temporary position.

AGK (Steam) V2 Beta .. : Windows 10 Pro, 8.1 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 24th Aug 2015 21:31
Thank you Hockeykid, that was a very understandable sollution that I will nick for my project.
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 24th Aug 2015 22:56
Quote: "or maybe with DrawSprite and a temporary position."

I've never thought of that! I need to test this out right now! brb.....

Login to post a reply

Server time is: 2024-04-26 20:37:35
Your offset time is: 2024-04-26 20:37:35