1JAWS Language Reference Manual 1. Introduction The JAWS programming language was designed to provide a platform for casual and experienced game designers to rapidly prototype and develop space shooter genre video games. The main focus behind the language was to eliminate the necessity for mastery of complex graphics and game physics implementation to allow the game designer to solely focus on game play design. Thus, the syntax and structure of the JAWS language strives for simplicity and ease of use. 2. Lexical Conventions 2.1 Comments Comments are segments of code that the programmer wants the compiler to ignore. Comments in the JAWS programming language are limited to one per line. Comments must begin with "//" and everything else on that line up to the carriage return "/n" is treated as a comment. 2.2 Whitespace In addition to comments, blanks, tabs, and carriage returns are ignored except where they are used to separate tokens. Tokens must be separated by at least one of the above. 2.3 Identifiers Identifiers consist of a sequence of letters and digits and must start with a letter. In addition to letters, the underscore "_" can also be used and counts as an alphabetic. Identifiers represent the names that are given to declared data types that are used. It is suggested that identifiers begin with a lowercase letter. However, this is not enforced syntax. 2.4 Keywords The following list of identifiers are reserved in the JAWS language and may not be used otherwise. int entity string movement boolean attack double point constant map if show else hide for true to false by while 2.5 Constants JAWS allows the use of 3 types of constants: int, string, and double. Constants are defined by typing the "constant" prefix before an identifier. For example, to define a constant called "HIGH_SCORE": constant string HIGH_SCORE = 100;2Constants retain their initial values and may not be changed during the execution of the program. It is suggested that constants be named with all uppercase letters to distinguish them from identifiers. However, this is not enforced syntax. 2.6 Separators The characters used as separators in JAWS are: ( ) { } , ; 2.7 Tokens Tokens are separated into identifiers, constants, keywords, operators, and other separators. Tokens are defined greedily meaning the token is the longest un-terminated recognized token type. All tokens must be separated by whitespace. 3. Data Types There are nine types of data in JAWS: int, double, string, boolean, point, entity, movement, attack, and map. 3.1.1 int Ints will be 32-bit two’s compliant integers. 3.1.2 double Doubles will be 64-bit double precision floating point numbers. 3.1.3 string Strings will be a character string beginning with a “ and ending with a “. JAWS will not support the single char data type so for single characters strings can be used in the same way. 3.1.4 boolean Booleans will be a true or false value. 3.1.5 point Since locations and points are so prevalent in JAWS, the point type is standard. Points consist of two ints, an x and a y, which uniquely define the point. The distance operator may be applied to point types, facilitating the calculation of distance between points and entities. Point type attributes may be directly accessed using the ‘s operator. Points are declared like a normal type and its x and y are defaulted to 0. Point has a built-in initializer that takes in an int x and an int y which may be called to initialized x and y. Here is an example: // point p will be at x = 0, y = 0 point p; // point p will be at x = 6, y = 4 point p = point(6,4); Point Type Attributes: Type Name Description int x x-coordinate of the point int y y-coordinate of the point 3.1.6 entity3Entities are objects that interact with each other during game play that are displayed to the user. Each entity has a set of attributes that describe fully the entity's behavior and look. Entities can be players, monsters, powerups, labels, and anything else that could appear on the map. It is up to the programmer to correctly define their behavior. Entity types in JAWS are all implemented as arrays. This facilitates the easy duplication of a multiplicity of entities without repeated declaration and initialization. When an entity class is created, all entities in its array are created with the same values. Each entity in the object array may be referenced and accessed individually thereafter. When an entity is referenced with an index specified, only that specific entity in the array is changed. When an index is left out, all entities in the array are affected. Entity classes have special built-in fucntions which facilitate game programming. The ~ (distance) operator can be applied on two entity classes and returns the distance between those two entities. Entities also have show and hide functions. Show is called to display the entity and to load its initializer. Hide is called to unload the entity from display. All attributes in a created entity class are set to default but can be initialized to different values in its initializer. To define the entity’s initializer, define a function with the name of the entity without a return type. The syntax for declaring an entity class and its initializer is as follows: // entity declaration entity name[multiplicity]; // entity initializer name() { [attribute] = newvalue; // initializing attributes . . [type] name = value; // adding user-defined variables . . } An example of creating a monster type called small_alien of multiplicity 5, and setting its constructor to lay them across horizontally, and creating user defined variables called hitpoints and pointValue: entity small_alien[5]; small_alien() { // individually set each small_alien’s location for i = 0 to 5 by 1 { small_alien[i]’s location = point(i*2, 0); } // set all small_alien's hitpoints to 10 int hitpoints = 10;4 int pointValue = 100; show(); } Entity Type Attributes: Type Name Description int height the height (in cells) of the entity on the map int width the width (in cells) of the entity on the map point location the location of the entity string image address of a supported image file to
View Full Document