It is currently Fri Nov 16, 2018 12:26 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Thu May 11, 2006 8:01 pm 
Offline
User avatar

Joined: Thu Nov 11, 2004 5:30 am
Posts: 121
Location: San Francisco, CA
Most 2d games also use simple damping on the camera movement. I observed one of the sonic games doing it, stole it and used it on pretty much every 2d camera i worked on.

Code:
; focus pos puts player in exact center
; of the viewport
focus_x = player_x - screen_width / 2;
focus_y = player_y - screen_height / 2;

; [ you can do a slack check here if you
; are making a laggy camera, omitted
; here for brevity]

; calc the difference from current pos,
; and use a fraction of that difference.
; this smooths out the camera movement.
; hopefully, your values have at least 2 bits
; of fixed-point fraction here. ;)
diff_x = (focus_x - scroll_x) / 4;
diff_y = (focus_y - scroll_y) / 4;

; clamp
if (diff_x > 0) diff_x = min(diff_x, min_x);
else diff_x = max(diff_x, -min_x);
if (diff_y > 0) diff_y = min(diff_y, min_y);
else diff_y = max(diff_y, -min_y);

; set
scroll_x += diff_x;
scroll_y += diff_y;

_________________
...patience...


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 9:04 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10972
Location: Rio de Janeiro - Brazil
Disch, your code seems to explain well what's going on. The window that Sonic has is indeed pretty narrow. And although it is quite tall, the camera tries to keep Sonic centered while he's on the ground. Maybe that's the trick?

Also, Sonic's position doesn't seem to have a direct influence on the position of the screen. I feel like the screen has it's own speed, wich is what Sonic affects, and is what allows him to move faster than the camera.

I though about the window approach before, but never tried it, thinking it would be bad to have more stuff behind you than in front of you. But if it is done like in Sonic, where the window is so narrow, it looks and feels ok. Also, as most of the Sonic action is left-to-right, I get the feel that the window is not exactly centered, it is placed a bit towards the left, leaving a larger visible area at the right, wich is where you'll usually be heading to.

baisoku, a quick scan through your code hasn't allowed me to understand it yet. I'm kinda sleepy now, I'll try to look at it again tomorrow.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 9:20 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20770
Location: NE Indiana, USA (NTSC)
tokumaru wrote:
Sonic's position doesn't seem to have a direct influence on the position of the screen. I feel like the screen has it's own speed, wich is what Sonic affects, and is what allows him to move faster than the camera.

Yes, the screen in Sonic the Hedgehog 2 has a maximum speed, and that is 2 rows of 8x8 pixel tiles in each dimension.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 9:33 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10972
Location: Rio de Janeiro - Brazil
tepples wrote:
Yes, the screen in Sonic the Hedgehog 2 has a maximum speed, and that is 2 rows of 8x8 pixel tiles in each dimension.

Wich allows us to achieve Sonic-like speeds on the NES. Even if moving on both axes. Of course, the complexity of any current events may slow it down, like the number of enemies on the screen and such, but technically, it is possible to have a smooth Sonic game (unlike the glitchy pirates Somari and Jurassic Boy) on the NES.

I plan to prove that one day, making a decent port of Sonic (still a pirate, though). Of course, a direct port would be boring, so I have to think of something new. Oh well...


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 9:43 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20770
Location: NE Indiana, USA (NTSC)
Draw a different anthropomorphic woodland creature and make a run cycle. Then you can make your own Sonic clone without having it be a "pirate original".


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 10:00 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10972
Location: Rio de Janeiro - Brazil
But then it's just lame...... =)

For some odd reason, a fan-game of an existing series feels much less lame than an obvious copy disguised to look like an original idea.

EDIT: There are thousands of Sonic games made with "Click N' Play" styled tools, and even some that were actually programmed, and they are never referred to as "pirate originals". Does the fact that these games are not made for profit change anything?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 10:40 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20770
Location: NE Indiana, USA (NTSC)
tokumaru wrote:
But then it's just lame......

Be lame or be sued. Remember what happened to The Great Giana Sisters?

Quote:
There are thousands of Sonic games made with "Click N' Play" styled tools, and even some that were actually programmed, and they are never referred to as "pirate originals".

Only because the developer of the original game hasn't referred to the clones as such. (And yes, I'm familiar with Clickteam's tools.)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 11:17 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10972
Location: Rio de Janeiro - Brazil
tepples wrote:
Be lame or be sued. Remember what happened to The Great Giana Sisters?

Actually I don't. I barelly know the game. Was the similarity to SMB enough to give any trouble to the peoplewho made this game?

Quote:
Only because the developer of the original game hasn't referred to the clones as such. (And yes, I'm familiar with Clickteam's tools.)

Oh well... About the tool, I said "styled" 'cause I think there are others around, I'm not familiar with the people who make them.

Anyway, having a game with characters named "Phonic", "Nails" and "Buckles" would not be enough to escape from a law suit, huh? I'd kinda like to use those names... =)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 12, 2006 7:25 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I wrote a simple SDL based scrolling demo in C. It shows four algorithms. Only the source is included, so you'll have to build it for your machine (post a Windows build if you make one). I wrote the source code such that it serves as a good shell for developing more scrolling algorithms.

scrolling_algos.zip

It includes one I like the most, which keeps the player near the left or right side of the screen based on the direction he's facing, but doesn't scroll unless the player is moving. It also gives the player some "wiggle" room before scrolling, so he can be moving one direction (with scrolling), then reverse direction and move a bit without scrolling the other direction.

edit: updated link


Last edited by blargg on Mon Aug 22, 2011 1:11 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri May 12, 2006 10:55 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20770
Location: NE Indiana, USA (NTSC)
tokumaru wrote:
tepples wrote:
Be lame or be sued. Remember what happened to The Great Giana Sisters?

Actually I don't. I barelly know the game. Was the similarity to SMB enough to give any trouble to the peoplewho made this game?

Yes. Wikipedia tells all.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 13, 2006 1:33 pm 
Offline
User avatar

Joined: Thu Nov 11, 2004 5:30 am
Posts: 121
Location: San Francisco, CA
blargg wrote:
I wrote a simple SDL based scrolling demo in C. It shows four algorithms. Only the source is included, so you'll have to build it for your machine (post a Windows build if you make one). I wrote the source code such that it serves as a good shell for developing more scrolling algorithms.


Win32 binary (Requires SDL.dll and run-time data from blargg's archive)

_________________
...patience...


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 13, 2006 2:03 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10972
Location: Rio de Janeiro - Brazil
Thanks for the binary. I used to think that the algorithm that moves the camera to show more stuff in front of you was annoying, but the one that does the same thing, but only when you're moving felt worse. It gives a certain feel of interruption...

If you are moving to the same side most of the time, the Sonic-type of camera feels good. Although the window in this demo was a bit large in my opinion.

It was nice to get a direct comparison of algorithms. I missed trying the vertical scrolling along with the horizontal, though.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group