Get the latest Education e-news
 

Go Back   Game Career Guide Forums > Programming
Forum Home Register Members List Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 01-05-2009, 08:39 AM   #11
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

Ohk..I've been banging my head for quite some time now..ghrr..im messing somewhere with the scrolling logic..

Here is what i do:
Code:
//From Player.cs

if (ScreenX - world.ViewPortX >= Constants.viewPortWidth / 2)
                world.ViewPortX++;
else if (ScreenX - world.ViewPortX < (Constants.viewPortWidth / 2) - 1)
                world.ViewPortX--;
where ScreenX = (int)Math.Floor(position.X / Constants.TileWidth);

It scrolls correctly for some part, but it stops scrolling when I reach the end of the screen. Any ideas, how can I improve upon the scrolling logic ?

Also, I have attached my code in .zip format
Attached Files
File Type: zip Ladder.zip (40.1 KB, 6 views)
brainydexter is offline   Reply With Quote
Old 01-05-2009, 04:08 PM   #12
mordekai
Junior Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss11
Location: Seattle WA
Default

I have a couple questions for this competition:

1) How much scrolling does our background have to have for this competition?

2) Would it be ok to make more of a SHMUP/platformer hybrid of sorts for this, or will that make judging to difficult (ie., apples and oranges) ?

really, they're the same question... just phrased differently.

thanks
-chris
__________________
my gamedev blog
mordekai is offline   Reply With Quote
Old 01-06-2009, 12:22 AM   #13
Claxon
Senior Member

Activity Longevity
0/20 18/20
Today Posts
0/11 ssssss345
Location: London
Default

In response to the scrolling question: Some scrolling, but how much is up to you. if you want a shmup platformer you can providing there is some scolling involved.

brainydexter: I've had a quick look at your code. The reason it's stopping is because you're clamping the maximum and minimum X position of your player object to the width of the play area. If you remove the clamping, the environment scrolls continuously (which is I assume what you want). The problem you have then is that your player moves faster than the environment so you'll need to tweak the updateScrollingFrame() method so that your player cannot escape the play area.
Claxon is offline   Reply With Quote
Old 01-06-2009, 01:19 AM   #14
Protector one
Moderator

Activity Longevity
2/20 17/20
Today Posts
1/11 ssssss698
Location: Netherlands
Default

Quote:
Originally Posted by mordekai View Post
1) How much scrolling does our background have to have for this competition?
I figure the background wouldn't have to scroll at all. What defines a scrolling shooter isn't the scrolling background, but scrolling sets of enemies/obstacles (usually towards the player).
These sets can of course consist of a single enemy or object, and not all sets need to scroll—'though most of them usually do.
__________________
My name is Louis. Hi!
Uh oh! The princess is in another signature!
Protector one is offline   Reply With Quote
Old 01-06-2009, 08:05 PM   #15
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

Quote:
Originally Posted by Claxon View Post

The reason it's stopping is because you're clamping the maximum and minimum X position of your player object to the width of the play area. If you remove the clamping, the environment scrolls continuously (which is I assume what you want). The problem you have then is that your player moves faster than the environment so you'll need to tweak the updateScrollingFrame() method so that your player cannot escape the play area.
You are correct. After some time, I realised this, and thus tried to fix it, which left me with a very unusual behaviour..

In order to display the entire map, I have to increment the viewport with 8, so that the player can scroll through the whole width of the map. Now, as soon as I increment the viewport by 8, each time it hits this logic, it really scrolls too fast, which looks very wierd.
Thereon, if I have to scroll left, and using the above said logic, if I decrement the viewport by 8, the logic really goes crazy.
Lastly, if I increment by 8, the condition goes for a toss:

Code:
ScreenX - world.ViewPortX >= Constants.viewPortWidth / 2
Now, am stuck and I really dont know how to proceed
brainydexter is offline   Reply With Quote
Old 01-07-2009, 12:12 AM   #16
Claxon
Senior Member

Activity Longevity
0/20 18/20
Today Posts
0/11 ssssss345
Location: London
Default

I think a couple of things that account for the 'weirdness' are:
  • Your player object moves in small increments, but the level moves 1 tile at a time
  • You are using the 'Position' of the player as the rendering X coordinate, so it will run off the side of the screen


The way I would handle your view position & player movement would be to store & update the player position as you are currently doing - this indicates your character's "World position".

Next update the viewport position to always display your character in the centre of the viewport (so
Code:
Viewport.x = player.Position.x - (Viewport.width / 2)
and the same for y). You may want to improve this later (once you've got it working) so that it will update it's position depending on how far from the viewport edge you are (the closer to the edge, the faster it moves to follow the character).

Now when you draw your character it's screen position would be Position.x - Viewport.x. Similarly to start rendering your level you will want to find out which the left-most tile will be with something along the lines of:

Code:
int tileIndex = (Viewport.X / TileWidth) % NumberOfHorizontalTilesInLevel
I hope that's helped. Let me know if you get stuck with anything.
Claxon is offline   Reply With Quote
Old 01-07-2009, 09:48 PM   #17
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

Thanks Claxon. It really dawned upon me as to what you were saying and I fixed the code. It scrolls now, all the way till the end

I am now working on collision detection. Lets see how this one goes

Thanks a ton !
brainydexter is offline   Reply With Quote
Old 01-08-2009, 04:40 AM   #18
Duckman
Member

Activity Longevity
0/20 17/20
Today Posts
0/11 sssssss84
Location: Tuckahoe, NY
Default

Hey guys, just wanted to give an update on how things are going. Right now I have the ability to show graphics using DirectX9, which is something that I couldn't do before so I'm somewhat moving on this. Now I need to get my ship to fire weapons and get a background in there to really give it some life. I had difficulty with collision detection with the pong game hopefully I won't have that this time. I'll keep you guys updated.
__________________
Mike M
Facebook Profile LinkedIn Profile
Duckman is offline   Reply With Quote
Old 01-08-2009, 02:05 PM   #19
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

I just posted a new FAQ section on my blog. If anybody else is also struggling with the scrolling part, they can check the FAQ section. Also, just shout if any bit of it is not clear

Hope it is of some use to the reader.

(Also, this is my first time at doing such things, thus if you have any sorts of suggestions, let me know.)
brainydexter is offline   Reply With Quote
Old 01-09-2009, 12:04 AM   #20
Claxon
Senior Member

Activity Longevity
0/20 18/20
Today Posts
0/11 ssssss345
Location: London
Default

Cool, I can see that FAQ being useful for newbies if you keep adding to it.
Claxon is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 05:08 PM.






UBM Tech