Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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 1099 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
http://www.java-gaming.org/topics/iconified/28984/view.html
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

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


Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (28 views)
2014-12-15 09:26:44

Mr.CodeIt (19 views)
2014-12-14 19:50:38

BurntPizza (35 views)
2014-12-09 22:41:13

BurntPizza (70 views)
2014-12-08 04:46:31

JscottyBieshaar (32 views)
2014-12-05 12:39:02

SHC (44 views)
2014-12-03 16:27:13

CopyableCougar4 (40 views)
2014-11-29 21:32:03

toopeicgaming1999 (108 views)
2014-11-26 15:22:04

toopeicgaming1999 (94 views)
2014-11-26 15:20:36

toopeicgaming1999 (29 views)
2014-11-26 15:20:08
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!