Skip to content

Commit

Permalink
Initial commit: "Empty Game" and "Default Game" template sources
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Mar 23, 2016
0 parents commit 2981329
Show file tree
Hide file tree
Showing 24 changed files with 5,269 additions and 0 deletions.
Binary file added Default Game/AGSFNT0.WFN
Binary file not shown.
Binary file added Default Game/AGSFNT1.WFN
Binary file not shown.
Binary file added Default Game/AGSFNT2.WFN
Binary file not shown.
2,883 changes: 2,883 additions & 0 deletions Default Game/Game.agf

Large diffs are not rendered by default.

521 changes: 521 additions & 0 deletions Default Game/GlobalScript.asc

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Default Game/GlobalScript.ash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Main header script - this will be included into every script in
// the game (local and global). Do not place functions here; rather,
// place import definitions and #define names here to be used by all
// scripts.
124 changes: 124 additions & 0 deletions Default Game/KeyboardMovement.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
================================================================================
CharacterControl script module for Adventure Game Studio v2.7
by Rui "Trovatore" Pires & strazer
================================================================================
Version 1.01

********************************************************************************
There may still be some things that need fixing. If you decide to try it out,
we'd appreciate some feedback at:
http://www.bigbluecup.com/yabb/index.php?topic=22724
********************************************************************************

Contents
========

1. - Introduction
2. - Features
3. - Changelog
4. - Setup
5. - Usage
6. - Customization


================================================================================
1. Introduction
================================================================================

This script module allows you to enable movement of the player character with
the keyboard.

You are free to use this for any game, free or commercial. A credit would be
nice but is not necessary.

Have fun! :)
Rui "Brisby" Pires & strazer


================================================================================
2. Features
================================================================================

* Move the player character with keyboard keys
* Choice of two control modes: Pressing or tapping direction keys


================================================================================
3. Changelog
================================================================================

Version 1.01 (2005-09-21)

* Clean-up & documentation by strazer

Version 1.00 (2005-09-20)

* First public release by Rui "Brisby" Pires


================================================================================
4. Setup
================================================================================

To use this script module in your game, you have to import it first:
Open your game in the AGS editor, go to menu "Script" -> "Module manager...",
click the "Import..." button and open the file "KeyboardMovement_101.scm".

You will now have access to the module from your global and room scripts.


================================================================================
5. Usage
================================================================================

The only function this script module currently exposes is

--------------------------------------------------------------------------------
KeyboardMovement.SetMode(KeyboardMovement_Modes mode);
--------------------------------------------------------------------------------

Call this function from anywhere in your script to choose a control mode and
thus enabling keyboard movement.
A good place to put it is your game's "game_start" function. You can call the
function again at a later time to change the control mode.

Three modes are currently available:

* eKeyboardMovement_None: Keyboard movement disabled (the default)

* eKeyboardMovement_Pressing: Player walks while the direction key is pressed.
Releasing the key stops the character.

* eKeyboardMovement_Tapping: Player starts walking when direction is pressed
once and walks until key is pressed again. Numpad-5 also stops him.

NOTE: The character can only be moved if he's standing on a walkable area.

NOTE: The player character will stop walking when he encounters an obstacle or
the end of the walkable area.

Example:

// global script

function game_start() {

KeyboardMovement.SetMode(eKeyboardMovement_Pressing);

}


================================================================================
6. Customization
================================================================================

I've made an effort to comment the code as much as possible to make it easier
to understand.
If you decide to alter the module, I ask you to please make clear that you have
changed it from the original version should you distribute your copy.

If you have any questions or suggestions, let us know at
http://www.bigbluecup.com/yabb/index.php?topic=22724

================================================================================
End of file
216 changes: 216 additions & 0 deletions Default Game/KeyboardMovement_102.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
// 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
};

//****************************************************************************************************
// 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
//****************************************************************************************************

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

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

KeyboardMovement_Directions newdirection; // declare variable storing new direction

// get new direction:
if ( ((IsKeyPressed(KeyboardMovement_KeyDown)) && (IsKeyPressed(KeyboardMovement_KeyRight))) || (IsKeyPressed(KeyboardMovement_KeyDownRight)) ) newdirection = eKeyboardMovement_DownRight; // if down&right arrows or PgDn (numeric pad) held down, set new direction to Down-Right
else if ( ((IsKeyPressed(KeyboardMovement_KeyUp)) && (IsKeyPressed(KeyboardMovement_KeyRight))) || (IsKeyPressed(KeyboardMovement_KeyUpRight)) ) newdirection = eKeyboardMovement_UpRight; // up&right arrows or PgUp (numpad)
else if ( ((IsKeyPressed(KeyboardMovement_KeyDown)) && (IsKeyPressed(KeyboardMovement_KeyLeft))) || (IsKeyPressed(KeyboardMovement_KeyDownLeft)) ) newdirection = eKeyboardMovement_DownLeft; // down&left arrows or End (numpad)
else if ( ((IsKeyPressed(KeyboardMovement_KeyUp)) && (IsKeyPressed(KeyboardMovement_KeyLeft))) || (IsKeyPressed(KeyboardMovement_KeyUpLeft)) ) newdirection = eKeyboardMovement_UpLeft; // up&left arrows or Home (numpad)
else if (IsKeyPressed(KeyboardMovement_KeyDown)) newdirection = eKeyboardMovement_Down; // down arrow
else if (IsKeyPressed(KeyboardMovement_KeyLeft)) newdirection = eKeyboardMovement_Left; // left arrow
else if (IsKeyPressed(KeyboardMovement_KeyRight)) newdirection = eKeyboardMovement_Right; // right arrow
else if (IsKeyPressed(KeyboardMovement_KeyUp)) newdirection = eKeyboardMovement_Up; // up arrow
else newdirection = eKeyboardMovement_Stop; // if none of the above held down, set it to stop player character

if (IsKeyPressed(KeyboardMovement_KeyStop)) newdirection = eKeyboardMovement_Stop; // if 5 (numeric pad) held down, stop player character, regardless of whether some of the above are held down

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

}

}

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

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;

}

//====================================================================================================
13 changes: 13 additions & 0 deletions Default Game/KeyboardMovement_102.ash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Script header for module 'KeyboardMovement'

#define KeyboardMovement_VERSION 101

enum KeyboardMovement_Modes {
eKeyboardMovement_None,
eKeyboardMovement_Tapping,
eKeyboardMovement_Pressing
};

struct KeyboardMovement {
import static function SetMode(KeyboardMovement_Modes mode);
};
Binary file added Default Game/_blank.crm
Binary file not shown.
Binary file added Default Game/acsprset.spr
Binary file not shown.
1 change: 1 addition & 0 deletions Default Game/room1.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// room script file
Binary file added Default Game/room1.crm
Binary file not shown.
Binary file added Default Game/template.ico
Binary file not shown.
Binary file added Empty Game/AGSFNT0.WFN
Binary file not shown.
Binary file added Empty Game/AGSFNT1.WFN
Binary file not shown.
Binary file added Empty Game/AGSFNT2.WFN
Binary file not shown.

0 comments on commit 2981329

Please sign in to comment.