Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Olleh19

#41


Code: ags
if (gamepad.GetAxis(0) < -20) \


{
do stuff
}



That type of "function" where you clearly should add forexample i guess the left button, but its not being used now, its been solved another way, which interests me.

So what i mean is here is that version of the button im going to use for the Z assigned keyboard.

As the example from the ags controller thread on here:

Code: ags
    if (gamepad.IsButtonDownOnce(11))
        {
           //click on Z button to get a punch.."guess working again"
        }
     


my Z button is in the Actions. This type of code not posting the whole code, no point in doing that.. Then i "get it". I hope....

Code: ags



Actions.Asc

   if (IsKeyPressed(eKeyZ))                  //PUNCH BUTTON HERE COMES THE MESS; Här börjar RÖRAN :DDDDDDDDD! 
  
   
{
    
    
    
    
    

    if (cAxl.Loop==2 || cAxl.Loop==3 || cAxl.Loop==4 || cAxl.Loop==5) //RIGHT PUNCH HIT, All loops are RIGHT/positioned player v_Axl_WalkAction 

{
    

#42
SUCCESS! It actually works.

I'm surprised. I thought i had to do syntax in the repeatedly???

Now with the Action Button on the keyboard Z, still tho.
Thats its own "function" i guess, its not part of the keyboard module. alltho i ofc would like it to be.

#43
Quote from: Crimson Wizard on Thu 29/10/2020 18:51:39
Ok, so, have you tried adding the code I suggested above, into the keyboardmovement module?

I'm not sure at which point you are currently.

Code: ags
// Main script for module 'KeyboardMovement'

//****************************************************************************************************
// DEFINITIONS
//****************************************************************************************************

#define DISTANCE 10000// distance player walks in Tapping mode before he stops

enum KeyboardMovement_Directions {
	eKeyboardMovement_Stop, 
	eKeyboardMovement_DownLeft, 
	eKeyboardMovement_Down, 
	eKeyboardMovement_DownRight, 
	eKeyboardMovement_Left, 
	eKeyboardMovement_Right, 
	eKeyboardMovement_UpLeft, 
	eKeyboardMovement_Up, 
	eKeyboardMovement_UpRight 
  //eKeyboardMovement_Punch, 
};

//****************************************************************************************************
// VARIABLES
//****************************************************************************************************

// keycodes as variables for future key customization functions (static variables?):
int KeyboardMovement_KeyDown = 380; // down arrow
int KeyboardMovement_KeyLeft = 375; // left arrow
int KeyboardMovement_KeyRight = 377; // right arrow
int KeyboardMovement_KeyUp = 372; // up arrow
int KeyboardMovement_KeyDownRight = 381; // PgDn (numpad)
int KeyboardMovement_KeyUpRight = 373; // PgUp (numpad)
int KeyboardMovement_KeyDownLeft = 379; // End (numpad)
int KeyboardMovement_KeyUpLeft = 371; // Home (numpad)
int KeyboardMovement_KeyStop = 376; // 5 (numpad)


KeyboardMovement_Modes KeyboardMovement_Mode = eKeyboardMovement_None; // stores current keyboard control mode (disabled by default)

KeyboardMovement_Directions KeyboardMovement_CurrentDirection = eKeyboardMovement_Stop; // stores current walking direction of player character

//****************************************************************************************************
// USER FUNCTIONS
//****************************************************************************************************

//====================================================================================================

static function KeyboardMovement::SetMode(KeyboardMovement_Modes mode) {
	KeyboardMovement_Mode = mode;
}

//====================================================================================================

// key customization functions here

//====================================================================================================

//****************************************************************************************************
// EVENT HANDLER FUNCTIONS
//****************************************************************************************************

Controller*gamepad;
//====================================================================================================

function game_start()
{
  gamepad = Controller.Open(0);
}

    int _dx, _dy;
    int left_frames, right_frames, up_frames, down_frames;
     
    function repeatedly_execute() {
     
            //--------------------------------------------------
            // Pressing mode
            //--------------------------------------------------
     
            if ((IsGamePaused() == true) || (KeyboardMovement_Mode != eKeyboardMovement_Pressing) || (IsInterfaceEnabled() == false) || (player.on == false)) return 0;
              // if game is paused, module or mode disabled, interface disabled or player character hidden, quit function
        
      bool left, up, right, down;
        
      if (IsKeyPressed(KeyboardMovement_KeyUpLeft)) { up = true; left = true; }
      if (IsKeyPressed(KeyboardMovement_KeyUp)) up = true;    
      if (IsKeyPressed(KeyboardMovement_KeyUpRight)) { up = true; right = true; }
      if (IsKeyPressed(KeyboardMovement_KeyRight)) right = true;    
      if (IsKeyPressed(KeyboardMovement_KeyDownRight)) { down = true; right = true; }  //I'll add the rest later if this works ofc!
      if (IsKeyPressed(KeyboardMovement_KeyDown)) down = true;    
      if (IsKeyPressed(KeyboardMovement_KeyDownLeft)) { down = true; left = true; }
      if (IsKeyPressed(KeyboardMovement_KeyLeft) || gamepad.GetAxis(0) > 20) left = true; 
      
      if (IsKeyPressed(KeyboardMovement_KeyStop)) { up = false; left = false; down = false; right = false; }
      
      if (left) left_frames++; else left_frames = 0;
      if (right) right_frames++; else right_frames = 0;
      if (left && right) {
        left = left_frames < right_frames;
        right = !left;
      }
      if (up) up_frames++; else up_frames = 0;
      if (down) down_frames++; else down_frames = 0;
      if (up && down) {
        up = up_frames < down_frames;
        down = !up;
      }
      
      int dx = right * DISTANCE - left * DISTANCE;
      int dy = down * DISTANCE - up * DISTANCE;
      
      if (dx != _dx || dy != _dy) player.WalkStraight(player.x + dx, player.y + dy, eNoBlock); // walk player character to the new coordinates
      
      _dx = dx; _dy = dy;
    }
//====================================================================================================

function on_key_press(int keycode) {

	//--------------------------------------------------
	// Tapping mode
	//--------------------------------------------------

	if ((IsGamePaused() == true) || (KeyboardMovement_Mode != eKeyboardMovement_Tapping) || (IsInterfaceEnabled() == false) || (player.on == false)) return 0;
	  // if game is paused, module or mode disabled, interface disabled or player character hidden, quit function

	KeyboardMovement_Directions newdirection; // declare variable storing new direction

	// get new direction:
	if (keycode == KeyboardMovement_KeyDownRight) newdirection = eKeyboardMovement_DownRight; // if down-right key pressed, set new direction to Down-Right
	else if (keycode == KeyboardMovement_KeyUpRight) newdirection = eKeyboardMovement_UpRight;
	else if (keycode == KeyboardMovement_KeyDownLeft) newdirection = eKeyboardMovement_DownLeft;
	else if (keycode == KeyboardMovement_KeyUpLeft) newdirection = eKeyboardMovement_UpLeft;
	else if (keycode == KeyboardMovement_KeyDown) newdirection = eKeyboardMovement_Down;
	else if (keycode == KeyboardMovement_KeyLeft) newdirection = eKeyboardMovement_Left;
	else if (keycode == KeyboardMovement_KeyRight) newdirection = eKeyboardMovement_Right;
	else if (keycode == KeyboardMovement_KeyUp) newdirection = eKeyboardMovement_Up;
	else if (keycode == KeyboardMovement_KeyStop) newdirection = eKeyboardMovement_Stop; // if stop key pressed, set to stop player character

	if (newdirection != KeyboardMovement_CurrentDirection) { // if new direction is different from current direction

		if (newdirection == eKeyboardMovement_Stop) player.StopMoving(); // if new direction is the Stop command, stop movement of player character
		else { // if new direction is NOT the Stop command

			int dx, dy; // declare variables storing new walk coordinates
			if (newdirection == eKeyboardMovement_DownRight) {
				dx = DISTANCE;
				dy = DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_UpRight) {
				dx = DISTANCE;
				dy = -DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_DownLeft) {
				dx = -DISTANCE;
				dy = DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_UpLeft) {
				dx = -DISTANCE;
				dy = -DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_Down) {
				dx = 0;
				dy = DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_Left) {
				dx = -DISTANCE;
				dy = 0;
			}
			else if (newdirection == eKeyboardMovement_Right) {
				dx = DISTANCE;
				dy = 0;
			}
			else if (newdirection == eKeyboardMovement_Up) {
				dx = 0;
				dy = -DISTANCE;
			}

			player.WalkStraight(player.x + dx, player.y + dy, eNoBlock); // walk player character to the new coordinates
		}
		KeyboardMovement_CurrentDirection = newdirection; // update current direction to new direction

	}
	else { // if new direction is same as current direction
		player.StopMoving(); // stop player character
		KeyboardMovement_CurrentDirection = eKeyboardMovement_Stop; // update current direction
	}

}

//====================================================================================================

function on_event(EventType event, int data) {

	if (event == eEventLeaveRoom) KeyboardMovement_CurrentDirection = eKeyboardMovement_Stop;

}

//====================================================================================================
#44
Yes, it does it was a mistake, i'm laughing out loud!

But i wonder what to call in the function KeyboardMovement_KeyLeft(); etc

Edit: yes, im testing it because before when i got null points previously those showed up no matter what action was in the button. So i usually try display or player.say...Bad way to test things? :-[
#45
I'm sorry. I should have "cleaned up" ofc all my "attempts" that's why you have Gamepad all over the place, and "open".
I'll try your suggestions now, i'll edit once done.


Edit: Ok, i mean what should i call now in repeatedly execute??

Code: ags

if (gamepad.GetAxis(0) < 20)
{
 
Display (""); 

}   


HAHA, ofc i get nothing, i didnt type anyrthing! (laugh)
#46
Quote from: Crimson Wizard on Thu 29/10/2020 18:27:22
Quote from: Olleh19 on Thu 29/10/2020 18:21:48
Edit again: Wait, so what you are saying is I HAVE TO replace ALL isKeyPressed with On_key_pressed is that what you are saying??

What... this is absolutely not what I was saying. Also, you can't just replace IsKeyPressed with on_key_pressed, they are things so different that are not replaceable...

I was suggesting to ADD "gamepad.GetAxis" condition to each "IsKeyPressed(KeyboardMovement_xxx)" condition inside the keyboard movement module.

But, first of all, I dont know what "gamepad" is, but hoped you know since you are using it elsewhere. Can you explain then, what is this "gamepad" variable, and how do you declare or get it?

EDIT: oh, nevermind, I found it in your script, you define this in GlobalScript.asc.
Ok, I need to think how to let keyboard module use this variable...

Oh, sorry i confused you with someone else. Sorry! I was told earlier to use On_Key_press for the action button instead. My bad!
Thank you very much for trying to help out in a tough situation(!)
#47
Thanks for the code Crimson. However i get a nullpoint referenced with it. I don't know what i'm doing wrong.
I replaced it  like you've said.

Edit: What should be called in the rep exec then?
Probably why i get null point...

Edit again: Wait, so what you are saying is I HAVE TO replace ALL isKeyPressed with On_key_pressed is that what you are saying??

I actually should have done this a couple of days ago, i've just been lazy. I "scripted it wrong" to start with, until i realised the "best way" is to use On_Key_press for the type of game i'm doing right now.
#48
Quote from: morganw on Thu 29/10/2020 18:12:05
102 is the old keyboard movement script, but perhaps that is still inside the Tumbleweed template.
Quote from: Crimson Wizard on Thu 29/10/2020 17:46:11Key Tapping mode means that pressing same key second time will make character stop moving. Because gamepad may send axis signals repeatedly, this may be received as multiple key presses in a row, and character will begin walking and stop walking immediately.
One of the changes in the replacement version was to fix the stuttering caused by this, although I only tested against the keyboard repeat rate.

IF, i've used the thumblweed template. Those scripts are DELETED inside this project. If that makes things worse, or better. I dont know!
#49
Quote from: Crimson Wizard on Thu 29/10/2020 18:08:03
Quote from: Olleh19 on Thu 29/10/2020 18:04:25
Omg, i don't even know!  :-[ I deleted most of the scripts. Is there anyway i see anywhere what it is?
I do believe this actually is the sierra  template tho, but most of the times i've used the Thumbleweed template.

Well, if you deleted most scripts, that may not be a problem anymore.

I'm confused. Am i totally off in the syntax, or should the things i wrote out "work" in theory? ???
#50
Quote from: Crimson Wizard on Thu 29/10/2020 18:01:19
Please tell what template do you use for your game. For instance, Sierra template comes with its own KeyboardMovement module, so first thing is to double check that it don't conflict with the one you imported.

Omg, i don't even know!  :-[ I deleted most of the scripts. Is there anyway i can see anywhere what it is?
I do believe this actually is the sierra  template tho, but most of the times i've used the Thumbleweed template.


Scripts i'm using. PPcollision & Keyboard Movement 102. From my eyes nothing is conflicting..I've already tried different keyboard scripts together before, and it was no issue.
So i lean towards what you've said in the previous post..


Code: ags



Globalscript.asc

Controller*gamepad;
function game_start()
{  



  gamepad = Controller.Open(0);

cAxl.SetIdleView(2, -30);
cEnemy1.SetIdleView(3, -30); 

 Mouse.ControlEnabled=false;
 Mouse.Visible=false;
 
KeyboardMovement.SetMode(eKeyboardMovement_Pressing);


  
   // set KeyboardMovement movement mode
  

}


// put anything you want to happen every game cycle in here

//JOYSTICK PLUGIN CONTROLLER BUTTONS


//11 = Start Button
//8 - Select Button
//7 - Trigger Right 1
//6 - Trigger Left 1
//5 - Trigger Right 2
//4 - Trigger Left 2

//3 - Square/Fyrkant
//2 - Cross/Kryss
//1 - Circle
//0 - Triangle/Trekant



function repeatedly_execute() 
{              



if (gamepad.GetAxis(0) < -20) 



Game.SimulateKeyPress(90);





if (gamepad.GetAxis(0) > 20)
{
 
cAxl.x++;

}

else if (gamepad.IsButtonDownOnce(3)) //RIGHT Hit

{
    


      cAxl.Animate (10, 0, eOnce, eNoBlock); 

      cAxl.SetIdleView(5, 0);                                                       

      cAxl.Baseline=0;                               
 

cAxl.Animate(10, 0, eOnce, eNoBlock);

}




 Enemy1_HealthBar(); //Checkar Enemy1's hälsa.

cEnemy1.FollowCharacter(cAxl);

if (Enemy_Type1_Death_Count==3)  //Set this to however many enemies of the TYPE1 you want to show up..


{
  cEnemy1.Clickable=true;
  cEnemy1.SetIdleView(3, 0);
  cEnemy1.LockViewFrame(3, 0, 0);
  cEnemy1.UnlockView(eKeepMoving);
  cEnemy1.SetIdleView(3, 0);
  cEnemy1.Transparency=0;
   Signal_Got_Hit=0;
  cEnemy1.ChangeRoom(2);
  gSignal_Healthbar.Visible=false;
 
Is_Enemy1_In_Storage=false;
Go_Next_Round();

}

  if (Is_Enemy1_In_Storage==true && Enemy_Type1_Death_Count==2)

{
                                                                      //Display ("DEATHCOUNT - 2 (TIME FOR LEFT SIDE ACTION");
Enemy_Type1_Respawn_LEFT();
Is_Enemy1_In_Storage=false;

}
else if (Is_Enemy1_In_Storage==false)

{

}

else if (Is_Enemy1_In_Storage==true && Enemy_Type1_Death_Count==1)

{
                                                                    //  Display ("DEATHCOUNT - 1 (TIME FOR RIGHT SIDE ACTION");
Enemy_Type1_Respawn_RIGHT();
Is_Enemy1_In_Storage=false;

}
   
  


Player_Actions();


  




}
 


function repeatedly_execute_always() 
     
{
  
}
        


// put here all enemy animations, hit's death animations, etc in here.
function late_repeatedly_execute_always() 
{
Trashcan_Beater();
Signal_Hit_Ground();


 Enemy1_HealthBar(); //Checkar Enemy1's hälsa.

cEnemy1.FollowCharacter(cAxl);

if (Enemy_Type1_Death_Count==3)  //Set this to however many enemies of the TYPE1 you want to show up..


{
  cEnemy1.Clickable=true;
  cEnemy1.SetIdleView(3, 0);
  cEnemy1.LockViewFrame(3, 0, 0);
  cEnemy1.UnlockView(eKeepMoving);
  cEnemy1.SetIdleView(3, 0);
  cEnemy1.Transparency=0;
   Signal_Got_Hit=0;
  cEnemy1.ChangeRoom(2);
  gSignal_Healthbar.Visible=false;
 
Is_Enemy1_In_Storage=false;
Go_Next_Round();

}

  if (Is_Enemy1_In_Storage==true && Enemy_Type1_Death_Count==2)

{
                                                                      //Display ("DEATHCOUNT - 2 (TIME FOR LEFT SIDE ACTION");
Enemy_Type1_Respawn_LEFT();
Is_Enemy1_In_Storage=false;

}
else if (Is_Enemy1_In_Storage==false)

{

}

else if (Is_Enemy1_In_Storage==true && Enemy_Type1_Death_Count==1)

{
                                                                    //  Display ("DEATHCOUNT - 1 (TIME FOR RIGHT SIDE ACTION");
Enemy_Type1_Respawn_RIGHT();
Is_Enemy1_In_Storage=false;

}
   
  
Signal_Hit_Ground();


}



// c

function dialog_request(int param) {
}




 
function on_key_press(eKeyCode keycode) 
{
  if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
  
  if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
  if (keycode == eKeyF9) RestartGame(); // F9
  if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx");  // F12
  if (keycode == eKeyCtrlS) Debug(0,0); // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV) Debug(1,0); // Ctrl-V, version
  if (keycode == eKeyCtrlA) Debug(2,0); // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX) Debug(3,0); // Ctrl-X, teleport to room
  //if (keycode == eKeyZ) Player_Actions();


}
function gPlayer_Healthbar_OnClick(GUI *theGui, MouseButton button)
{

}

function b_Player_Health_OnClick(GUIControl *control, MouseButton button)
{

}

#51
Edit: Crimson, i'm using Pressing mode btw!

Is this perhaps what you mean?


Code: ags
// Main script for module 'KeyboardMovement'

//****************************************************************************************************
// DEFINITIONS
//****************************************************************************************************

#define DISTANCE 10000// distance player walks in Tapping mode before he stops

enum KeyboardMovement_Directions {
	eKeyboardMovement_Stop, 
	eKeyboardMovement_DownLeft, 
	eKeyboardMovement_Down, 
	eKeyboardMovement_DownRight, 
	eKeyboardMovement_Left, 
	eKeyboardMovement_Right, 
	eKeyboardMovement_UpLeft, 
	eKeyboardMovement_Up, 
	eKeyboardMovement_UpRight 
  //eKeyboardMovement_Punch, 
};

//****************************************************************************************************
// VARIABLES
//****************************************************************************************************

// keycodes as variables for future key customization functions (static variables?):
int KeyboardMovement_KeyDown = 380; // down arrow
int KeyboardMovement_KeyLeft = 375; // left arrow
int KeyboardMovement_KeyRight = 377; // right arrow
int KeyboardMovement_KeyUp = 372; // up arrow
int KeyboardMovement_KeyDownRight = 381; // PgDn (numpad)
int KeyboardMovement_KeyUpRight = 373; // PgUp (numpad)
int KeyboardMovement_KeyDownLeft = 379; // End (numpad)
int KeyboardMovement_KeyUpLeft = 371; // Home (numpad)
int KeyboardMovement_KeyStop = 376; // 5 (numpad)


KeyboardMovement_Modes KeyboardMovement_Mode = eKeyboardMovement_None; // stores current keyboard control mode (disabled by default)

KeyboardMovement_Directions KeyboardMovement_CurrentDirection = eKeyboardMovement_Stop; // stores current walking direction of player character

//****************************************************************************************************
// USER FUNCTIONS
//****************************************************************************************************

//====================================================================================================

static function KeyboardMovement::SetMode(KeyboardMovement_Modes mode) {
	KeyboardMovement_Mode = mode;
}

//====================================================================================================

// key customization functions here

//====================================================================================================

//****************************************************************************************************
// EVENT HANDLER FUNCTIONS
//****************************************************************************************************

Controller*gamepad;
//====================================================================================================
    int _dx, _dy;
    int left_frames, right_frames, up_frames, down_frames;
     
    function repeatedly_execute() {
     
            //--------------------------------------------------
            // Pressing mode
            //--------------------------------------------------
     
            if ((IsGamePaused() == true) || (KeyboardMovement_Mode != eKeyboardMovement_Pressing) || (IsInterfaceEnabled() == false) || (player.on == false)) return 0;
              // if game is paused, module or mode disabled, interface disabled or player character hidden, quit function
        
      bool left, up, right, down;
        
      if (IsKeyPressed(KeyboardMovement_KeyUpLeft)) { up = true; left = true; }
      if (IsKeyPressed(KeyboardMovement_KeyUp)) up = true;    
      if (IsKeyPressed(KeyboardMovement_KeyUpRight)) { up = true; right = true; }
      if (IsKeyPressed(KeyboardMovement_KeyRight)) right = true;    
      if (IsKeyPressed(KeyboardMovement_KeyDownRight)) { down = true; right = true; }
      if (IsKeyPressed(KeyboardMovement_KeyDown)) down = true;    
      if (IsKeyPressed(KeyboardMovement_KeyDownLeft)) { down = true; left = true; }
      if (IsKeyPressed(KeyboardMovement_KeyLeft)) left = true;
      
      if (IsKeyPressed(KeyboardMovement_KeyStop)) { up = false; left = false; down = false; right = false; }
      
      if (left) left_frames++; else left_frames = 0;
      if (right) right_frames++; else right_frames = 0;
      if (left && right) {
        left = left_frames < right_frames;
        right = !left;
      }
      if (up) up_frames++; else up_frames = 0;
      if (down) down_frames++; else down_frames = 0;
      if (up && down) {
        up = up_frames < down_frames;
        down = !up;
      }
      
      int dx = right * DISTANCE - left * DISTANCE;
      int dy = down * DISTANCE - up * DISTANCE;
      
      if (dx != _dx || dy != _dy) player.WalkStraight(player.x + dx, player.y + dy, eNoBlock); // walk player character to the new coordinates
      
      _dx = dx; _dy = dy;
    }
//====================================================================================================

function on_key_press(int keycode) {

	//--------------------------------------------------
	// Tapping mode
	//--------------------------------------------------

	if ((IsGamePaused() == true) || (KeyboardMovement_Mode != eKeyboardMovement_Tapping) || (IsInterfaceEnabled() == false) || (player.on == false)) return 0;
	  // if game is paused, module or mode disabled, interface disabled or player character hidden, quit function

	KeyboardMovement_Directions newdirection; // declare variable storing new direction

	// get new direction:
	if (keycode == KeyboardMovement_KeyDownRight) newdirection = eKeyboardMovement_DownRight; // if down-right key pressed, set new direction to Down-Right
	else if (keycode == KeyboardMovement_KeyUpRight) newdirection = eKeyboardMovement_UpRight;
	else if (keycode == KeyboardMovement_KeyDownLeft) newdirection = eKeyboardMovement_DownLeft;
	else if (keycode == KeyboardMovement_KeyUpLeft) newdirection = eKeyboardMovement_UpLeft;
	else if (keycode == KeyboardMovement_KeyDown) newdirection = eKeyboardMovement_Down;
	else if (keycode == KeyboardMovement_KeyLeft) newdirection = eKeyboardMovement_Left;
	else if (keycode == KeyboardMovement_KeyRight) newdirection = eKeyboardMovement_Right;
	else if (keycode == KeyboardMovement_KeyUp) newdirection = eKeyboardMovement_Up;
	else if (keycode == KeyboardMovement_KeyStop) newdirection = eKeyboardMovement_Stop; // if stop key pressed, set to stop player character

	if (newdirection != KeyboardMovement_CurrentDirection) { // if new direction is different from current direction

		if (newdirection == eKeyboardMovement_Stop) player.StopMoving(); // if new direction is the Stop command, stop movement of player character
		else { // if new direction is NOT the Stop command

			int dx, dy; // declare variables storing new walk coordinates
			if (newdirection == eKeyboardMovement_DownRight) {
				dx = DISTANCE;
				dy = DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_UpRight) {
				dx = DISTANCE;
				dy = -DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_DownLeft) {
				dx = -DISTANCE;
				dy = DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_UpLeft) {
				dx = -DISTANCE;
				dy = -DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_Down) {
				dx = 0;
				dy = DISTANCE;
			}
			else if (newdirection == eKeyboardMovement_Left) {
				dx = -DISTANCE;
				dy = 0;
			}
			else if (newdirection == eKeyboardMovement_Right) {
				dx = DISTANCE;
				dy = 0;
			}
			else if (newdirection == eKeyboardMovement_Up) {
				dx = 0;
				dy = -DISTANCE;
			}

			player.WalkStraight(player.x + dx, player.y + dy, eNoBlock); // walk player character to the new coordinates
		}
		KeyboardMovement_CurrentDirection = newdirection; // update current direction to new direction

	}
	else { // if new direction is same as current direction
		player.StopMoving(); // stop player character
		KeyboardMovement_CurrentDirection = eKeyboardMovement_Stop; // update current direction
	}

}

//====================================================================================================

function on_event(EventType event, int data) {

	if (event == eEventLeaveRoom) KeyboardMovement_CurrentDirection = eKeyboardMovement_Stop;

}

//====================================================================================================
#52
QuoteCan you post the definition of this KeyboardMovement_KeyLeft ? From the module's script or header, not sure where it is defined.

That was just an example, that didn't work. It's not defined anywhere else then in the keyboard module 102's script. Since i've imported that script. That's all i've done.

I don't know if this is what you look for when you say defined, but here is how i've "defined" the Z button. Is it wrong?
I've also tried to add this code into the global script/header, but no success. I'm doing something wrong, clearly.

As for definition for the leftarrow otherwise all i can say is that yeah it's the keyboard modules script working. I'm not assigning anything different to them.

All i do is "check for loops" if player is turned there, that happens, etc.

That code is coming from a custom script called Actions, that i'm working on.  i have NOTHING in Actions.Ash tho.



Actions.asc


Code: ags


//Actions.asc 

   if (IsKeyPressed(eKeyZ))                  //PUNCH BUTTON HERE COMES THE MESS; Här börjar RÖRAN :DDDDDDDDD! 
  
   
{
    
    
    
    
    

    if (cAxl.Loop==2 || cAxl.Loop==3 || cAxl.Loop==4 || cAxl.Loop==5) //RIGHT PUNCH HIT, All loops are RIGHT/positioned player v_Axl_WalkAction 

{
    


      cAxl.Animate (10, 0, eOnce, eNoBlock); 

      cAxl.SetIdleView(5, 0);                                                       

      cAxl.Baseline=0;
}
  

     else if (cAxl.IdleView==5)   //RIGHT-PUNCH - Empty in the Air Punch, No Target Hit.
{
   


     cAxl.UnlockView();
     cAxl.Animate (10, 0, eOnce, eNoBlock); 
     cAxl.SetIdleView(5, 0);                                                             

     cAxl.Baseline=0;
}
 
     else if (cAxl.IdleView==4)   //LEFT-PUNCH - Empty in the Air Punch, No Target Hit.
{
    


    cAxl.UnlockView();
    cAxl.Animate (11, 0, eOnce, eNoBlock); 
    cAxl.SetIdleView(4, 0);                                                             

    cAxl.Baseline=0;
}
#53
I have been hiting my head against the wall for a couple of hours now.
I have just finally got the AGS controller working.
I cannot get it to assign the movement buttons or the action button (Z) from my keyboard. I'm using the Keyboard Module 102.
I've only managed to do it by triggering the direct animations onto the pad itself, which is a totally dumb way of doing it, and limiting ofc. :-[
I'm thinking perhaps i need to import the scripts into the global script and then do something..I just don't know what syntax i'm looking for, at all.
The manual unfortunaly does not have a section on the basic usages of the AGS controller  :~(

Edit: I'm using isKeyPressed not On_Key_Press, maybe that's the issue?!
I mean looking at the scripts it does look like the ASCII or the eLeftArrow has been replaced with the modules own nicknames. ???
Still that don't explain why i get no action with simulate eKeyZ.  (roll). Just like always i'm misinterpreting AGS features. Hence the user description AGS n00b.

Code: ags


GlobalScript.asc

if (gamepad.GetAxis(0) < -20) 



Game.SimulateKeyPress(KeyboardMovement_KeyLeft);  //or eKeyLeftArrow, or (for action button attempts) eKeyZ or 90...Out of ideas. 










#54
Quote from: Crimson Wizard on Thu 29/10/2020 10:36:27


Explanation of various repeatedly_execute functions is here: https://github.com/adventuregamestudio/ags-manual/wiki/RepExec

repeatedly_execute_always is run before game updates itself, which means it will be always 1 step behind (all properties have values from last update). This function is still useful to adjust some things before game updates, if you want to affect that update.
late_repeatedly_execute_always is run after game updates itself, which means it will access up-to-date property values. This function is useful if your code is relying on current game state.

Thanks for the update on that! Very much appreciate this guys! I thought i was doomed there for a second! (laugh)

#55
Quote from: Snarky on Thu 29/10/2020 07:26:27
Instead of room_RepExec(), try creating a late_repeatedly_execute_always() function in your room script and placing the viewport positioning code there.

!!! Thank you very much Snarky! AGS is a mystery sometimes to me, but that made the stuttering disappear. VERY cool(!)
#56
Quote from: Crimson Wizard on Wed 28/10/2020 17:54:46
I forgot to add this example in my last post:

If your camera's line can be described with a graph function (remember school, y = 2x + 10, and so on), then you may take one coordinate from player's position and calculate another using this function. Only subtract starting position from x (or y), like 700 in your case.
Again, simply an example:
Code: ags

int x = player.x - Game.Camera.Width / 2;
int y = (x - 700) + 10; // a simple linear function
Game.Camera.SetAt(x, y);


Thank you very much! I have a lot to process and trial & error, but it feels nice to see the room scroll downwards, it's a win just that!

Edit: What's sad tho is one issue, brings up another one i'm using Keyboard Movement 102 i probably need to change. Why? The character start stuttering while moving upRight or DownRight, , DownLeft, etc etc.
He has always been slower or acting a bit strange when going "sideways". But it was very noticeable now when the room starts scrolling it affects him very badly, unfortunaly.

I'm using Movementlinkedtoanimation = false, all modules i've tried seems to be in love with that other mode, that no matter what settings i use, always ends up looking very bad.
Just talking about "looks" here. Perhaps linkedtoanimation is "the best" alternative.





#57
Quote from: Crimson Wizard on Wed 28/10/2020 17:48:38
If camera should be going along diagonal line, then you need to change both x and y parameter in SetAt.

For the example, centering camera on player's feet is: "Game.Camera.SetAt(player.x - Game.Camera.Width / 2, player.y - Game.Camera.Height / 2);".


In general, if the camera must move strictly along certain line, then one has to build a normal vector (perpendicular) from player's position to that line and find coordinates where these lines cross. But this may be too much for your case (if it's only one room).
If all your game is like this, then perhaps its worth writing such general algorithm.

I'm afraid I cannot explain this all in detail now, as I am very tired today and my head not working well too. I hope someone like Khris can join this topic :).

Don't worry my friend(!). Take the rest of the day off! This is not the game of the year i'm working on here....
Actually, it was in the 90's, i'm quite sure  (laugh) I'm trying to recreate a classic, so that in the future a different (let's put it that way) type of game could be done in AGS aswell. It's been requested before in the beginners section. Myself included, and eventually i thought let's dive into it, and see where it get's me. I hope the drawing don't spoil it.............. (laugh). Yes, let's hope he shows up! Poor Khris, always get's to do that hard work in beginners technical questions (laugh)


Edit: The last synthax that you gave, make it look reasonable ok. So it's close. I need to figure out what his Y position should be so the camera doesn't "jump" there when he reaches the 700 & whatever Y it should be. I'm again just shooting in the dark, guessworking.

#58
HALLELUJA there it was! But now when he reaches the end it should be able to scroll downwards too.
You don't need to give me exact numbers, just a basic idea. Then i keep fiddling with it!

But ONLY after x>700 thats where the RED LINE is drawn on the image, and teh room starts going downwards, as you can see it's going downwards in an angle, but i don't think the angle "matters" to the code that much?
It's just the fact that it should be able to scroll down after the 700px reach of the character.


Edit: BTW, these kind of settings. Where are they in the manual? I wished i could find em  (laugh)

Edit: Changing it to height, trying around here. Getting some strange, yet intresting results ! (laugh). Maybe this is a case where i would need more Cameras as the manual talks about being possible.

Code: ags
function room_RepExec()
{


{


  Game.Camera.SetAt(player.x - Game.Camera.Width / 2, 4);

 if (cAxl.x>700 && cAxl.y>203)
 {
     Game.Camera.SetAt(player.x - Game.Camera.Width / 2, 4);
Game.Camera.SetAt(player.x - Game.Camera.Height / 2, 90);


 }

}
}


Well things certainly change when reaching the destination now, not to it's intention (Scroll downwards after x 700 and y 203) tho, but at least something! Close but no cigar, as of yet. Just guessworking here.
#60
Quote

Could you try explaining what you are trying to achieve in simple language, without refering to code? Like, you want camera to follow after character, but not like default ags, and do ... what instead?


The camera should follow the character like it would in a normal room situation, but with the difference that the Y settings (that is locked, yes i know X is locked too). X needs to get unlocked so room scrolls normally to the sides.

Like if the game was 320px wide..ok I import a image that is 6000px wide? What does AGS do? It scrolls to the sides! Do you understand now?  :)

If i don't lock the room i get the look of IMAGE 1!

SMF spam blocked by CleanTalk