Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-29-2010, 07:18 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Platforming and slopes

Anyone have any suggestions on how to accomplish this? I've tried checking for slope tiles ahead of movement, and incrementing the player.y accordingly(if a 45 degree angle, increment player.y the same as speed, if a 22.5 degree angle, half the speed)... but that's proved unreliable, especially at speeds not divisible by .25. Not only that, but it's not a solid detection(for instance, if the player falls on a slope, nothing would happen).

Right now I'm using NPC's and simply using testnpc(since an NPC inherits the shape of the image) to 'stick' the player onto the slope of the NPC in pixel precision, but this is also proving unreliable at higher speeds.
Reply With Quote
  #2  
Old 01-29-2010, 11:58 PM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
I had something where the world was represented as lines stored in arrays instead of tiles, it handeled slopes easily and perfectly (Just draw a collision mask over the level).

There's tons of examples of line intersection algorithms online, then just find the line you hit's normal and you can work off that.

Alternatively you could just as easily automatically convert the tiles into lines for collision.
Reply With Quote
  #3  
Old 01-30-2010, 01:22 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by 12171217 View Post
I had something where the world was represented as lines stored in arrays instead of tiles, it handeled slopes easily and perfectly (Just draw a collision mask over the level).

There's tons of examples of line intersection algorithms online, then just find the line you hit's normal and you can work off that.

Alternatively you could just as easily automatically convert the tiles into lines for collision.
Well, could come up with an algorithm to create the lines on slopes, just make lines from corner to corner of blocking tiles. The rest could be handled normally.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #4  
Old 01-30-2010, 01:40 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Quote:
Originally Posted by coreys View Post
Well, could come up with an algorithm to create the lines on slopes, just make lines from corner to corner of blocking tiles. The rest could be handled normally.
Yeah I said that in the last sentence =P

Only reason I did it manually was because I liked the control.. It added a bit more depth to have the player moving like, a tad up and down on a surface that's actually a flat tile. If you show a tile layer above the player's feet it would look really nice like that, once V6 comes out.
Reply With Quote
  #5  
Old 01-30-2010, 05:40 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by 12171217 View Post
Yeah I said that in the last sentence =P

Only reason I did it manually was because I liked the control.. It added a bit more depth to have the player moving like, a tad up and down on a surface that's actually a flat tile. If you show a tile layer above the player's feet it would look really nice like that, once V6 comes out.
Hm, that's true. It's always nice to allow for flexibility, though I'm thinking the line collision detection would be slower than normal tile collision detection (some more math involved there), which is why I suggested using normal tile collision for everything else. But if the performance difference isn't particularly noticeable would be best to just do it all as you suggested.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #6  
Old 01-30-2010, 05:43 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Quote:
Originally Posted by coreys View Post
Hm, that's true. It's always nice to allow for flexibility, though I'm thinking the line collision detection would be slower than normal tile collision detection (some more math involved there), which is why I suggested using normal tile collision for everything else. But if the performance difference isn't particularly noticeable would be best to just do it all as you suggested.
If you segment the level into "zones" of lines, you're only tracing against like 10-15 lines max, really. It's not too intense. I've had a test NPC on N-Pulse where you draw lines around players and they have to slash them (And they use the same line intersection algorithm to detect the point where hit, and they dynamically segement at that point, it's cool =3), and it traces up to around 50 lines at once, as there's no optimization on it whatsoever. Myself, nor other players, have complained with it or visibly slowed down when I used it either.
Reply With Quote
  #7  
Old 01-30-2010, 07:27 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Well I'm talking about using lines as a base for collision detection
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #8  
Old 01-30-2010, 07:54 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
So am I. It's only around 10-15 lines maximum that are being tested against each frame. It's not a lot.
Reply With Quote
  #9  
Old 01-30-2010, 08:09 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Well then
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #10  
Old 01-30-2010, 08:13 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Hmm... well I was hoping for something a little less complicated. I really wish there was a nice open-source platformer with good code and physics, since just about every free platformer out there sucks ass.

If I can manage the line intersection that'd be cool, but it'd be automatic(every time you enter the level). Kai did once post a script that translated all walls into an array of lines, along with the ability to detect collisions. What does worry me is that I'd want this to be able to work flawlessly on a gmap, and processing that when player enters a new level would possibly cause a slight hang-up. I should also mention this would be in GS1.
Reply With Quote
  #11  
Old 01-30-2010, 10:53 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Hmm, this is what I currently came up with:
PHP Code:
function CheckForSlopes() {
  if (
this.vely != 0) return;
  for (
i=0;i<4;i+=1/16) {
    if (
tiles[playerx+1.5,playery+1.5+iin this.left45) {
      
this.onslope 1;
      
playery int(playery+i)-((playerx+1.5)%1);
      break;
    }
  }
  if (
== 4) {
    if (
this.onslope == 1playery int(playery+(this.velx .5 0));
    
this.onslope 0;
  }

Reply With Quote
Reply


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

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

Forum Jump


All times are GMT +2. The time now is 05:13 AM.


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