home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Special: Spiele Hits
/
Hits-CD.iso
/
aminet
/
spiele
/
ammud1_1.lha
/
AmigaMUD
/
Src
/
Basics
/
graphics.m
< prev
next >
Wrap
Text File
|
1997-05-28
|
44KB
|
1,659 lines
/*
* Amiga MUD
*
* Copyright (c) 1997 by Chris Gray
*/
/*
* graphics.m - some stuff to do simple graphics.
*/
private tp_graphics CreateTable()$
use tp_graphics
define t_graphics p_rName1 CreateStringProp()$
define t_graphics p_rName2 CreateStringProp()$
define t_graphics p_rBackGroundPen CreateIntProp()$
define t_graphics p_rForeGroundPen CreateIntProp()$
define t_graphics p_rEdgePen CreateIntProp()$
define t_graphics p_rDoorPen CreateIntProp()$
define t_graphics p_rCursorX CreateFixedProp()$
define t_graphics p_rCursorY CreateFixedProp()$
define t_graphics p_rDrawAction CreateActionProp()$
define t_graphics p_pStandardButtonsNow CreateBoolProp()$
define tp_graphics p_rAutoGraphics CreateBoolProp()$
define tp_graphics p_rAutoDrawAction CreateActionProp()$
define tp_graphics p_pXBase CreateIntProp()$
define tp_graphics p_pYBase CreateIntProp()$
/* first, some names for the standard colours */
define t_graphics C_BLACK 0$
define t_graphics C_DARK_GREY 1$
define t_graphics C_MEDIUM_GREY 2$
define t_graphics C_LIGHT_GREY 3$
define t_graphics C_WHITE 4$
define t_graphics C_BRICK_RED 5$
define t_graphics C_RED 6$
define t_graphics C_RED_ORANGE 7$
define t_graphics C_ORANGE 8$
define t_graphics C_GOLD 9$
define t_graphics C_CADMIUM_YELLOW 10$
define t_graphics C_LEMON_YELLOW 11$
define t_graphics C_LIME_GREEN 12$
define t_graphics C_GREEN 13$
define t_graphics C_LIGHT_GREEN 14$
define t_graphics C_DARK_GREEN 15$
define t_graphics C_FOREST_GREEN 16$
define t_graphics C_BLUE_GREEN 17$
define t_graphics C_AQUA 18$
define t_graphics C_LIGHT_AQUA 19$
define t_graphics C_SKY_BLUE 20$
define t_graphics C_LIGHT_BLUE 21$
define t_graphics C_BLUE 22$
define t_graphics C_DARK_BLUE 23$
define t_graphics C_VIOLET 24$
define t_graphics C_PURPLE 25$
define t_graphics C_FLESH 26$
define t_graphics C_PINK 27$
define t_graphics C_TAN 28$
define t_graphics C_BROWN 29$
define t_graphics C_MEDIUM_BROWN 30$
define t_graphics C_DARK_BROWN 31$
/*
* ColourMatch - a routine to map name to number at run-time
*/
define t_graphics proc public ColourMatch(string name)int:
if name == "grey" then
C_MEDIUM_GREY
elif name == "red" then
C_RED
elif name == "green" then
C_GREEN
elif name == "blue" then
C_BLUE
else
MatchName(
"black.grey;dark.grey;medium.grey;light.white.red;brick.red."
"red-orange.orange.gold.yellow;cadmium.yellow;lemon.green;lime."
"green.green;light.green;dark.green;forest.blue-green.aqua."
"aqua;light.blue;sky.blue;light.blue.blue;dark.violet.purple."
"flesh.pink.tan.brown.brown;medium.brown;dark", name)
fi
corp;
/*
* ColourName - map from colour number to colour name
*/
define t_graphics proc public ColourName(int colour)string:
case colour
incase C_BLACK: "black"
incase C_DARK_GREY: "dark grey"
incase C_MEDIUM_GREY: "medium grey"
incase C_LIGHT_GREY: "light grey"
incase C_WHITE: "white"
incase C_BRICK_RED: "brick red"
incase C_RED: "red"
incase C_RED_ORANGE: "red-orange"
incase C_ORANGE: "orange"
incase C_GOLD: "gold"
incase C_CADMIUM_YELLOW: "cadmium yellow"
incase C_LEMON_YELLOW: "lemon yellow"
incase C_LIME_GREEN: "lime green"
incase C_GREEN: "green"
incase C_LIGHT_GREEN: "light green"
incase C_DARK_GREEN: "dark green"
incase C_FOREST_GREEN: "forest green"
incase C_BLUE_GREEN: "blue green"
incase C_AQUA: "aqua"
incase C_LIGHT_AQUA: "light aqua"
incase C_SKY_BLUE: "sky blue"
incase C_LIGHT_BLUE: "light blue"
incase C_BLUE: "blue"
incase C_DARK_BLUE: "dark blue"
incase C_VIOLET: "violet"
incase C_PURPLE: "purple"
incase C_FLESH: "flesh"
incase C_PINK: "pink"
incase C_TAN: "tan"
incase C_BROWN: "brown"
incase C_MEDIUM_BROWN: "medium brown"
incase C_DARK_BROWN: "dark brown"
default: "<BAD-COLOUR>"
esac
corp;
/*
* ShowKnownColours - print the colour names that we understand.
*/
define t_graphics proc public ShowKnownColours()void:
int i;
Print("Known colours are: ");
for i from C_BLACK upto C_MEDIUM_BROWN do
Print(ColourName(i));
Print(", ");
od;
Print(ColourName(C_DARK_BROWN));
Print("\n");
corp;
/* tools for providing unique map group and effect id values */
/* some standard MapGroup values */
define t_graphics UNKNOWN_MAP_GROUP -1$
define t_graphics NO_MAP_GROUP 0$
define t_graphics AUTO_MAP_GROUP 1$
define tp_graphics GraphicsThing CreateThing(nil)$
define tp_graphics p_NextMapGroup CreateIntProp()$
define tp_graphics p_NextEffectId CreateIntProp()$
GraphicsThing@p_NextMapGroup := AUTO_MAP_GROUP + 1$
GraphicsThing@p_NextEffectId := 1$
define t_graphics proc public NextMapGroup()int:
int g;
g := GraphicsThing@p_NextMapGroup;
GraphicsThing@p_NextMapGroup := g + 1;
g
corp;
define t_graphics proc public NextEffectId()int:
int id;
id := GraphicsThing@p_NextEffectId;
GraphicsThing@p_NextEffectId := id + 1;
id
corp;
/* next, some general titling stuff */
define tp_graphics ROOM_NAME_BOX_ID NextEffectId()$
define tp_graphics NAME_BOX_COLS 18$
define t_graphics proc public DrawRoomNameBox()void:
int i, cols;
if not KnowsEffect(nil, ROOM_NAME_BOX_ID) then
cols := GCols(nil) / 2;
DefineEffect(nil, ROOM_NAME_BOX_ID);
GAMovePixels(nil, cols + (cols - NAME_BOX_COLS * 8 - 12) / 2, 0);
for i from 0 upto 3 do
GSetPen(nil, i + 1);
GRectanglePixels(nil, NAME_BOX_COLS * 8 + 12 - 2 * i, 29 - 2 * i,
false);
GRMovePixels(nil, 1, 1);
od;
EndEffect();
fi;
CallEffect(nil, ROOM_NAME_BOX_ID);
corp;
define t_graphics proc public DrawRoomName(string s1, s2)void:
int len, cols, col;
cols := GCols(nil) / 2;
col := cols + (cols - NAME_BOX_COLS * 8 - 12) / 2;
GSetPen(nil, C_BLACK);
GAMovePixels(nil, col + 6, 6);
GRectanglePixels(nil, NAME_BOX_COLS * 8, 17, true);
GSetPen(nil, C_GOLD);
len := Length(s2);
if len ~= 0 then
if len > NAME_BOX_COLS then
len := NAME_BOX_COLS;
s2 := SubString(s2, 0, NAME_BOX_COLS);
fi;
GAMovePixels(nil, col + 6 + (NAME_BOX_COLS - len) * 4, 21);
GText(nil, s2);
len := Length(s1);
if len > NAME_BOX_COLS then
len := NAME_BOX_COLS;
s1 := SubString(s1, 0, NAME_BOX_COLS);
fi;
GAMovePixels(nil, col + 6 + (NAME_BOX_COLS - len) * 4, 12);
GText(nil, s1);
else
len := Length(s1);
if len > NAME_BOX_COLS then
len := NAME_BOX_COLS;
s1 := SubString(s1, 0, NAME_BOX_COLS);
fi;
GAMovePixels(nil, col + 6 + (NAME_BOX_COLS - len) * 4, 17);
GText(nil, s1);
fi;
corp;
define tp_graphics HORIZONTAL_DOOR_ID NextEffectId()$
define tp_graphics VERTICAL_DOOR_ID NextEffectId()$
define tp_graphics NORTHWEST_DOOR_ID NextEffectId()$
define tp_graphics NORTHEAST_DOOR_ID NextEffectId()$
define t_graphics proc public HorizontalDoor()void:
if not KnowsEffect(nil, HORIZONTAL_DOOR_ID) then
DefineEffect(nil, HORIZONTAL_DOOR_ID);
GRMove(nil, 0.0, -0.01);
GRDraw(nil, 0.0, 0.021);
GRMove(nil, 0.0, -0.01);
GRDraw(nil, 0.03125, 0.0);
GRMove(nil, 0.0, -0.01);
GRDraw(nil, 0.0, 0.021);
EndEffect();
fi;
CallEffect(nil, HORIZONTAL_DOOR_ID);
corp;
define t_graphics proc public VerticalDoor()void:
if not KnowsEffect(nil, VERTICAL_DOOR_ID) then
DefineEffect(nil, VERTICAL_DOOR_ID);
GRMove(nil, -0.003, 0.0);
GRDraw(nil, 0.007, 0.0);
GRMove(nil, -0.003, 0.0);
GRDraw(nil, 0.0, 0.081);
GRMove(nil, -0.003, 0.0);
GRDraw(nil, 0.007, 0.0);
EndEffect();
fi;
CallEffect(nil, VERTICAL_DOOR_ID);
corp;
define t_graphics proc public NorthWestDoor()void:
if not KnowsEffect(nil, NORTHWEST_DOOR_ID) then
DefineEffect(nil, NORTHWEST_DOOR_ID);
GRMove(nil, -0.003, -0.012);
GRDraw(nil, 0.007, 0.021);
GRMove(nil, -0.003, -0.012);
GRDraw(nil, -0.013, 0.041);
GRMove(nil, -0.003, -0.012);
GRDraw(nil, 0.007, 0.021);
EndEffect();
fi;
CallEffect(nil, NORTHWEST_DOOR_ID);
corp;
define t_graphics proc public NorthEastDoor()void:
if not KnowsEffect(nil, NORTHEAST_DOOR_ID) then
DefineEffect(nil, NORTHEAST_DOOR_ID);
GRMove(nil, 0.003, -0.01