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 / scrolling on shot

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 8th Mar 2013 11:07 Edited at: 8th Mar 2013 11:27
been trying to get good scrolling but using getspritex(cannon) and getspritey(cannon) with setviewoffset() aint good enough as it jumps straight to it of course, so consider i have a sprite called cannon and another called cannonball, how would i have it scroll nicely after the cannonball passes through the centre of the screen ?
here is what I have tried so far:



The code for what i need is in the main do-loop, most of the other functions are remmed out for the sake of not needing external media!

Hail to the king, baby!
Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 9th Mar 2013 00:01
Maybe something like this is what you're looking for?...

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 9th Mar 2013 14:06 Edited at: 9th Mar 2013 14:06
There are a couple of ways I'd look at it. Both involve calculating the position of the middle of the screen.

1) you could position the middle of the screen at the mid point between the canon and the ball

This would put the canon in the middle of the screen until it fires and then the screen would scroll at half the speed of the ball until both reach the edge.

What happens next is up to you.

2) Use a Smallest( valueA , valueB ) function - there's at least one in the community functions, but they're not hard.

Pass the default screen middle and the ball y position through this and use the result for the y position of the middle of the screen
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 9th Mar 2013 20:58 Edited at: 9th Mar 2013 21:08
I would have a camera target x/y(cannonball) and take the difference between camera-target and camera-actual x/y, use a fraction of that to increase camera-actual each frame. How much of the fraction between target and actual camera position you want to use will determine the speed of the camera panning.

If you are only moving the camera on let's say X you don't need to complicate much:



if you want to move on both x and y and keep it smooth, but also include code to set the viewpoint back to the cannon after the ball is gone I would do something like:



Try camSpeed to something like 10 or even 20

That's just me, and this is saturday night so I've had a couple of glasses of red wine already. Code not tested


Edit: And to prevent the screen to move before the cannonball hits the middle of the screen I would have something like:



My hovercraft is full of eels

Login to post a reply

Server time is: 2024-05-06 18:58:10
Your offset time is: 2024-05-06 18:58:10