AGS Snake

From Adventure Game Studio | Wiki
Jump to: navigation, search

AGS Snake makes creation of small snake-like arcade mini-games possible. It's developed by FSi and v0.1.0 is currently available.

Manual

Functions

SnakeGame.StartGame(int starting_length, int spd, int col, SnakeDirection dir);

Starts the snake with spedified starting length, speed (spd) and direction (dir) using sprite set col. dir can be sdNorth, sdSouth, sdEast or sdWest.

SnakeGame.EndGame(bool Notify);

Ends the game (displaying "Game Over" message if Notify is set to true).

SnakeGame.DisplayScore();

Displays score.

SnakeGame.SnakeLength();

Returns length of a snake. Function is rather slow, so care to assign its value to a variable if you plan to use it multiple times.

SetBonusType(int idx, int scr, int ls, int spr);

Sets parameters of bonus type idx. Scr - score (~length boost) awarded for that bonus; ls - bonus's life span; spr - sprite slot to draw it.


Configuration

Configuration is (as of v0.1.0) rather complex.

First one would change the constants at the beginning of module header to one's liking (or leave them unchanged if the defaults suit them).

Then before calling SnakeGame.StartGame(), one need to set a bunch of parameters, i.e.:

  • int SnakeGame.SnakeSpeed - number of loops passed before next move is calculated
  • int SnakeGame.CellHeight - height of a game field's cell (in pixels)
  • int SnakeGame.CellWidth - width of a game field's cell (in pixels)
  • int SnakeGame.FieldX - X coordinate of game field's upper left corner
  • int SnakeGame.FieldY - Y coordinate of game field's upper left corner
  • int SnakeGame.SizeX - width of game field (in cells)
  • int SnakeGame.SizeY - height of game field (in cells)
  • int SnakeGame.FieldSprite - sprite of game field (used to clear it before each move)
  • bool SnakeGame.ShowScore - use internal routine to display score, if true, then following parameters take effect:
    • int SnakeGame.ScoreBG - background colour (from palette)
    • int SnakeGame.ScoreFG - foreground colour (from palette)
    • int SnakeGame.ScoreHeight - height of rectangle drawn behind score text
    • int SnakeGame.ScoreWidth - width of rectangle drawn behind score text
    • int SnakeGame.ScoreX - X coordinate of score text
    • int SnakeGame.ScoreY - Y coordinate of score text
    • int SnakeGame.ScoreFont - font to print the score with
  • SnakeColorSprites[i] - sprite slot used to draw body of a snake.
  • SnakeHeadsSprites[i] - sprite slit used to draw head of a snake.

Set more than one to have more than one snake type.

Call SetBonusType(int idx, int scr, int ls, int spr) to set all bonuses (MAX_BONUS_TYPES times). Parameters are: idx - array index, scr - length increment, ls - life span, spr - sprite slot ID.

Caveats

Generally very simple implementation, need to work on it further.


Download

Download-wise it comes in two files: sources (module and demo game) and compiled demo game (for previews).

Revision History:

27 Jun 2007 - v0.1.0 First public beta

License

AGSSnake AGS script module
Copyright (C) 2007 Ivan 'FSi' Firsov
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA