Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Side Scrolling(Up and down)  (Read 2028 times)
0 Members and 1 Guest are viewing this topic.
Offline cubemaster21
« Posted 2012-04-24 20:21:21 »

I'm trying to make my game so that once you go higher than the top of the screen, the screen will begin to scroll with you, but I have no idea how to do this, the current method that i have right now, checks to see if the player's y value is lower than 0, and if it is, then it adds to my Y offset. but it just keeps adding and adding. Any help with this?

Check out my game, Viking Supermarket Smash
Offline ReBirth
« Reply #1 - Posted 2012-04-25 02:55:04 »

In my approach I'll take use of bufferimage and swap it to roll. But it's hard to maintain and use lots of memory.

Offline jammas615

Junior Devvie

Projects: 1

« Reply #2 - Posted 2012-04-25 03:01:20 »

it just keeps adding and adding.

Are you sure it's not checking and adding an offset but the player's y is always less than 0?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jonjava
« Reply #3 - Posted 2012-04-25 04:11:48 »

Yeah you probably want to have an offset based on the screen or player position in your drawing methods so you can cancel out the difference and have things remain visible.

1). The tiles move WITH the screen. It does what it's supposed to do, because the screen position changes, so should the tiles used to represent the new position of the screen:

[SOLUTION]: If we want the visible screen/canvas to stay in place, we simply alter the horizontal and vertical offsets to cancel out the screens x and y position.[size=8pt]( that we're already familiar with from the OP )[/size]. I.e: horOffset = -screen.xPosition(); verOffset = -screen.yPosition();

So our paint method would look something like this

int horOff = screen.xPosition();
int verOff = screen.yPosition();
drawImage(sprite, isoX() - horOff,
                            isoY() - verOff, null);

Pages: [1]
  ignore  |  Print  

EgonOlsen (37 views)
2018-06-10 19:43:48

EgonOlsen (20 views)
2018-06-10 19:43:44

EgonOlsen (39 views)
2018-06-10 19:43:20

DesertCoockie (186 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (861 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (139 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!