Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   A couple questions about gravity. (https://forums.graalonline.com/forums/showthread.php?t=134260822)

Cubical 10-15-2010 01:03 AM

A couple questions about gravity.
 
I'm currently working on a side scroller and I'm wondering if there's a way to walk up and down angled tiles or images if that's what's needed? If so could someone point me in the right direction?

My other question is, would it be better to rescript the entire movement system when working with gravity or just rescript what's needed for the gravity to work.

fowlplay4 10-15-2010 01:04 AM

Yeah you'll definitely need to go with a custom movement system.

DustyPorViva 10-15-2010 01:09 AM

I'm pretty sure I released the code to my Mario in Graal remake: http://forums.graalonline.com/forums...hp?t=134257825

Although it's in GS1, it should help you out as it contains gravity and more importantly, the slopes you are asking about.

My method for dealing with slopes was to designate a portion of the tileset to specifically angled slopes, and while those tiles were under the player, snap the player to it proportionally to their position on the tile. For example if a 45degree angled slope is under the player, their y position would be player.y = int(player.y) + player.x%1; Of course, this depends on the direction of the angle. Shallow slopes get a bit more complicated as it begins getting into multiple tile detection, but again, all the code is there.

As for gravity you should definitely start from scratch, it's painful to try to get gravity working with default movement. Hell, even on a small event on UN I ended up coding all custom movement and hit detection just because it was a platformer event.

Also, I seriously suggest putting the physics in a class so you can join all appropriate objects to it, so you can easily apply the worlds physics to all objects.

Cubical 10-15-2010 01:28 AM

I just looked at the code and I'm not that good with math so would there be a simpler way to do it using images or is it pretty much the same concept?

DustyPorViva 10-15-2010 01:50 AM

Quote:

Originally Posted by Cubical (Post 1606276)
I just looked at the code and I'm not that good with math so would there be a simpler way to do it using images or is it pretty much the same concept?

With images you may be able to do so by manipulating the blocking properties of npc's and onwall. Place an NPC with the slope as the image. Since onwall only considers the actual image blocking and transparency as nonblocking, you can use to pretty much "snap" the player to the closest position of the visual slope. It's hackish, though, as that's what I originally attempted to do.

Cubical 10-15-2010 01:55 AM

Quote:

Originally Posted by DustyPorViva (Post 1606285)
With images you may be able to do so by manipulating the blocking properties of npc's and onwall. Place an NPC with the slope as the image. Since onwall only considers the actual image blocking and transparency as nonblocking, you can use to pretty much "snap" the player to the closest position of the visual slope. It's hackish, though, as that's what I originally attempted to do.

So it wouldn't work as smoothly?

DustyPorViva 10-15-2010 02:18 AM

Quote:

Originally Posted by Cubical (Post 1606288)
So it wouldn't work as smoothly?

I don't remember exactly why I ditched the method, to be honest.


All times are GMT +2. The time now is 12:41 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.