Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-20-2012, 10:48 AM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
Custom movement issue.

I have made a simple custom movement system. The movement is a 'arcade' type movement. You can move in all four directions, but the player can only be seen from a side view.

A issue I am having is that I am not sure how to make it so the player can run diangle also. (Ex-Move up and right at the same time)

And if someone could throw in a line of tile detection that'd be great!

PHP Code:
//#CLIENTSIDE
function onCreated()
{
player.zoom 1;
disabledefmovement();
}

function 
onKeyPressed()
{
 if (
player.clientr.canmove == 1)
 {
 if (!
this.moving){
 
this.moving true;
 
onTimeOut();
  }
 }
}

function 
onTimeOut()
{
if (
player.clientr.canmove == 1)
{
 if (
keydown(3))
 {
 
player.+=0.8;
 
player.dir 3;


 
setAni("walk"NULL);
 
 
setTimer(0.2);
} else if (
keydown(1)){
   
player.-=0.8;
 
player.dir 1;
  
setAni("walk"NULL);

 
  
setTimer(0.2);
  
  } else if (
keydown(0)){
   
player.-=0.5;
  
setAni("walk"NULL);
 
setTimer(0.2);
 
  } else if (
keydown(2)){
   
player.+=0.5;
  
setAni("walk"NULL);
 
setTimer(0.2); 
  
} else {
 
this.moving false;
}
if (
this.moving) {
setTimer(0.05);
} else {

 
setAni("idle"NULL);
 } 
}

Reply With Quote
  #2  
Old 05-20-2012, 11:37 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
get rid of your else statements.
Have it so it's like this
PHP Code:
if (keydown(0)){

}
else if (
keydown(2)){

}

if (
keydown(1)){

}
else if (
keydown(3)){


I'd also suggest use vecx and y to make your script shorter

PHP Code:
for (temp.i=0;i<4;i++){
  if (
keydown(i)){
    
player.+= vecx(i)*client.playerSpeed;
    
player.+= vecy(i)*client.playerSpeed;
  }

I've intentionally left out the onwall detection for you to do btw so you can understand the concept. Have fun.
Reply With Quote
  #3  
Old 05-20-2012, 04:44 PM
greggiles greggiles is offline
Registered User
greggiles's Avatar
Join Date: Sep 2007
Posts: 149
greggiles has a spectacular aura about
Thanks! But I don't mean write the onWall for me. I just need an idea what it looks like
Reply With Quote
  #4  
Old 05-21-2012, 12:06 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
I gave you an idea, if you don't understand even that just say so and I'm sure either me someone else will break it all down for you.
You might also want to take a look at this guide made by dusty which elaborates quite well on all the things you need to know.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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 06:11 AM.


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