Okay, this might or might not work (but it should). It's the beginning of the

Ruamoko standard library overhaul.
This commit is contained in:
Jeff Teunissen 2002-08-17 05:27:34 +00:00
parent 52588e0698
commit 5e1ce57322
36 changed files with 763 additions and 309 deletions

View File

@ -1,7 +1,7 @@
#ifndef __client_menu_h
#define __client_menu_h
#include "inputline.h"
#include "InputLine.h"
@extern inputline_t input_active;

View File

@ -3,7 +3,7 @@
#include "cmd.h"
#include "draw.h"
#include "key.h"
#include "inputline.h"
#include "InputLine.h"
#include "string.h"
#include "../include/string.h"
#include "math.h"

View File

@ -33,7 +33,7 @@
#include "draw.h"
#include "cvar.h"
#include "key.h"
#include "inputline.h"
#include "InputLine.h"
#include "controls_o.h"
#include "options_util.h"

View File

@ -1,6 +1,6 @@
#include "menu.h"
#include "draw.h"
#include "inputline.h"
#include "InputLine.h"
#include "options_util.h"
#include "controls_o.h"
#include "client_menu.h"

18
ruamoko/game/Axe.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef __Axe_h
#define __Axe_h
#include "Object.h"
#include "Entity.h"
#include "Weapon.h"
@interface Axe: Object <Weapon>
{
Entity owner;
float damage;
}
- (id) init;
@end
#endif //__Axe_h

View File

@ -1,37 +1,39 @@
#include "axe.h"
#include "gameent.h"
#include "math.h"
#include "physics.h"
#include "qw_message.h"
#include "sound.h"
#include "tempent.h"
#include "world.h"
#include "GameEntity.h"
#include "World.h"
#include "Axe.h"
@implementation Axe
-init
- (id) init
{
[super init];
damage = (deathmatch > 3) ? 75.0 : 20.0;
return self;
}
-setOwner:(Entity)o
- (void) setOwner: (Entity) o
{
owner = o;
return self;
}
-fire
- (void) fire
{
local entity s = [owner ent];
local vector org, source;
makevectors (s.v_angle);
source = s.origin + '0 0 16';
traceline (source, source + v_forward * 64, NO, s);
if (trace_fraction == 1.0)
return self;
return;
org = trace_endpos - v_forward * 4;
@ -48,7 +50,6 @@
WriteCoord (MSG_MULTICAST, org_z);
multicast (org, MULTICAST_PVS);
}
return self;
}
@end

View File

@ -1,7 +1,7 @@
#ifndef __gameent_h
#define __gameent_h
#ifndef __GameEntity_h
#define __GameEntity_h
#include "entity.h"
#include "Entity.h"
@extern .vector angles;
@extern .float modelindex;
@ -17,7 +17,9 @@
@extern .vector v_angle;
@interface GameEntity: Entity
- (BOOL) takeDamage: weapon :inflictor :attacker : (float)damage;
@end
#endif//__gameent_h
#endif //__GameEntity_h

View File

@ -1,4 +1,4 @@
#include "gameent.h"
#include "GameEntity.h"
.vector angles;
.float modelindex;
@ -14,6 +14,7 @@
.vector v_angle;
@implementation GameEntity
- (BOOL) takeDamage: weapon : inflictor : attacker : damage
{
return NO;

View File

@ -12,7 +12,7 @@ STRIP=$(shell echo `echo -n $(srcdir)/ | sed -e 's/[^/]//g' | wc -c`)
pkgdata_DATA= game.dat
game_src= axe.r gameent.r tempent.r world.r
game_src= Axe.r GameEntity.r World.r tempent.r
%.qfo: %.r
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -p $(STRIP) -c -o $@ $<

13
ruamoko/game/Weapon.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef __Weapon_h
#define __Weapon_h
#include "Entity.h"
@protocol Weapon
- (void) setOwner: (Entity)o;
- (void) fire;
@end
#endif //__Weapon_h

82
ruamoko/game/World.r Normal file
View File

@ -0,0 +1,82 @@
#include "GameEntity.h"
#include "World.h"
id world;
integer deathmatch;
#define MAX_BODIES 8
@interface BodyQueue: Object
{
entity [MAX_BODIES] bodies;
integer head;
}
- (id) init;
- (void) addEntity: (GameEntity)ent;
@end
@implementation BodyQueue
- (id) init
{
local integer i;
id (self) = [super init];
self.head = NIL;
for (i = 0; i < MAX_BODIES; i++) {
local GameEntity ent = NIL;
id(ent) = [[GameEntity alloc] init];
self.bodies[i] = ent.ent;
}
}
- (void) addEntity: (GameEntity)ent
{
local entity be = bodies[head++];
local entity e = [ent ent];
be.angles = e.angles;
be.model = e.model;
be.modelindex = e.modelindex;
be.frame = e.frame;
be.colormap = e.colormap;
be.movetype = e.movetype;
be.velocity = e.velocity;
be.flags = 0;
setorigin (be, e.origin);
setsize (be, e.mins, e.maxs);
}
@end
@interface World: GameEntity
{
id bodyque;
}
- (void) spawn: (entity)ent;
- (void) copyToBodyQueue: (GameEntity)ent;
@end
@implementation World
- spawn: (entity)ent
{
[self initWithEntity: ent];
bodyque = [[BodyQueue alloc] init];
}
- (void) copyToBodyQueue: (GameEntity)ent
{
[bodyque addEntity: ent];
}
@end
void () worldspawn =
{
world = [[World alloc] initWithEntity: @self];
};

View File

@ -1,15 +0,0 @@
#ifndef __axe_h
#define __axe_h
#include "entity.h"
#include "weapon.h"
@interface Axe : Object <Weapon>
{
Entity owner;
float damage;
}
-init;
@end
#endif//__axe_h

View File

@ -1,11 +0,0 @@
#ifndef __weapon_h
#define __weapon_h
#include "entity.h"
@protocol Weapon
-setOwner:(Entity)o;
-fire;
@end
#endif//__weapon_h

View File

@ -1,70 +0,0 @@
#include "gameent.h"
#include "world.h"
id world;
integer deathmatch;
#define MAX_BODIES 8
@interface BodyQue : Object
{
entity [MAX_BODIES] bodies;
integer head;
}
-init;
-add:(GameEntity)ent;
@end
@implementation BodyQue
-init
{
local integer i;
[super init];
self.head = 0;
for (i = 0; i < MAX_BODIES; i++)
self.bodies[i] = [GameEntity new];
}
-add:(GameEntity)ent
{
local entity be = bodies[head++];
local entity e = [ent ent];
be.angles = e.angles;
be.model = e.model;
be.modelindex = e.modelindex;
be.frame = e.frame;
be.colormap = e.colormap;
be.movetype = e.movetype;
be.velocity = e.velocity;
be.flags = 0;
setorigin (be, e.origin);
setsize (be, e.mins, e.maxs);
return self;
}
@end
@interface World : GameEntity
{
BodyQue bodyque;
}
-spawn:(entity)ent;
-copyToBodyQue:(GameEntity)ent;
@end
@implementation World
-spawn:(entity)ent
{
[self initWithEntity:ent];
id (bodyque) = [[BodyQue alloc] init];
}
-copyToBodyQue:(GameEntity)ent
{
[bodyque add:ent];
}
@end
void () worldspawn =
{
world = [[World alloc] initWithEntity:@self];
};

51
ruamoko/include/Entity.h Normal file
View File

@ -0,0 +1,51 @@
/*
Entity.h
Entity class definition
Copyright (C) 2002 Bill Currie <taniwha@quakeforge.net>
Copyright (C) 2002 Jeff Teunissen <deek@quakeforge.net>
This file is part of the Ruamoko Standard Library.
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 program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __ruamoko_Entity_h
#define __ruamoko_Entity_h
#include "Object.h"
#include "entities.h"
@interface Entity: Object
{
@public
entity ent;
}
- (id) init;
- (id) initWithEntity: (entity) e;
- (void) free;
- (entity) ent;
@end
#endif //__ruamoko_Entity_h

View File

@ -1,7 +1,7 @@
#ifndef __ruamoko_inputline_h
#define __ruamoko_inputline_h
#ifndef __ruamoko_InputLine_h
#define __ruamoko_InputLine_h
#include "point.h"
#include "Rect.h"
#define OLD_API // FIXME update the input line api
@ -24,16 +24,22 @@ typedef _inputline_t [] inputline_t;
@interface InputLine: Object
{
Point at;
Rect frame;
inputline_t il;
}
-free;
-initAt:(Point)p HistoryLines:(integer)l LineSize:(integer)s PromptChar:(integer)prompt;
-setWidth:(integer)visibleWidth;
-process:(integer)key;
-draw:(BOOL)cursor;
-setText:(string)text;
-(string)getText;
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char;
//-initAt:(Point)p HistoryLines:(integer)l LineSize:(integer)s PromptChar:(integer)prompt;
- (void) free;
- (void) setWidth: (integer)width;
- (void) draw: (BOOL)cursor;
- (void) processInput: (integer)key;
- (id) setText: (string)text;
- (string) text;
@end
#endif //__ruamoko_inputline_h

View File

@ -1,10 +1,10 @@
AUTOMAKE_OPTIONS= foreign
includedir= $(prefix)/include/QF/ruamoko
include_HEADERS= \
crudefile.h debug.h entity.h infokey.h math.h message.h nq_message.h \
object.h physics.h qw_message.h qw_physics.h qw_sys.h sound.h \
string.h system.h \
crudefile.h debug.h entities.h infokey.h math.h message.h nq_message.h \
physics.h qw_message.h qw_physics.h qw_sys.h sound.h string.h system.h \
\
draw.h key.h inputline.h point.h \
draw.h key.h \
\
cbuf.h cmd.h cvar.h file.h
cbuf.h cmd.h cvar.h file.h \
Object.h Entity.h InputLine.h Point.h Rect.h Size.h

View File

@ -1,5 +1,5 @@
#ifndef __ruamoko_object_h
#define __ruamoko_object_h
#ifndef __ruamoko_Object_h
#define __ruamoko_Object_h
typedef enum {
NO,
@ -134,4 +134,4 @@ typedef enum {
//-awake;
@end
#endif//__ruamoko_object_h
#endif //__ruamoko_Object_h

27
ruamoko/include/Point.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef __ruamoko_Point_h
#define __ruamoko_Point_h
#include "Object.h"
@interface Point: Object
{
@public
integer x;
integer y;
}
- (id) initWithComponents: (integer)_x : (integer)_y;
- (id) initWithPoint: (Point)aPoint;
- (id) copy;
- (void) addPoint: (Point)aPoint;
- (void) subtractPoint: (Point)aPoint;
- (integer) x;
- (integer) y;
- (void) setPoint: (Point)aPoint;
@end
#endif //__ruamoko_Point_h

39
ruamoko/include/Rect.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef __ruamoko_Rect_h
#define __ruamoko_Rect_h
#include "Object.h"
#include "Point.h"
#include "Size.h"
@interface Rect: Object
{
@public
Point origin;
Size size;
}
- (id) initWithOrigin: (Point)_origin size: (Size)_size;
- (id) initWithComponents: (integer)x : (integer)y : (integer)w : (integer)h;
- (id) initWithRect: (Rect)aRect;
- (id) copy;
- (BOOL) intersectsRect: (Rect)aRect;
- (BOOL) containsPoint: (Point)aPoint;
- (BOOL) containsRect: (Rect)aRect;
- (BOOL) isEqualToRect: (Rect)aRect;
- (BOOL) isEmpty;
- (Rect) intersectionWithRect: (Rect)aRect;
- (Rect) unionWithRect: (Rect)aRect;
- (Rect) insetBySize: (Size)aSize;
- (Rect) offsetBySize: (Size)aSize;
- (Point) origin;
- (Size) size;
- (void) setSize: (Size)aSize;
@end
#endif //__ruamoko_Rect_h

61
ruamoko/include/Size.h Normal file
View File

@ -0,0 +1,61 @@
#ifndef __ruamoko_Size_h
#define __ruamoko_Size_h
#include "Object.h"
#include "Point.h"
#include "Size.h"
@interface Size: Object
{
@public
integer width;
integer height;
}
- (id) initWithWidth: (integer)w height: (integer)h;
- (id) initWithSize: (Size)aSize;
- (id) copy;
- (void) addSize: (Size)aSize;
- (void) subtractSize: (Size)aSize;
- (integer) width;
- (integer) height;
- (void) setSize: (Size)aSize;
- (void) setWidth: (integer)_width;
- (void) setHeight: (integer)_width;
@end
@interface Rect: Object
{
@public
Point origin;
Size size;
}
- (id) initWithOrigin: (Point)_origin size: (Size)_size;
- (id) initWithComponents: (integer)x : (integer)y : (integer)w : (integer)h;
- (id) initWithRect: (Rect)aRect;
- (id) copy;
- (BOOL) intersectsRect: (Rect)aRect;
- (BOOL) containsPoint: (Point)aPoint;
- (BOOL) containsRect: (Rect)aRect;
- (BOOL) isEqualToRect: (Rect)aRect;
- (BOOL) isEmpty;
- (Rect) intersectionWithRect: (Rect)aRect;
- (Rect) unionWithRect: (Rect)aRect;
- (Rect) insetBySize: (Size)aSize;
- (Point) origin;
- (Size) size;
- (void) setSize: (Size)aSize;
@end
#endif//__ruamoko_point_h

View File

@ -1,13 +1,91 @@
/*
debug.h
Debugging function definitions
Copyright (C) 2002 Bill Currie <taniwha@quakeforge.net>
Copyright (C) 2002 Jeff Teunissen <deek@quakeforge.net>
This file is part of the Ruamoko Standard Library.
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 program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __ruamoko_debug_h
#define __ruamoko_debug_h
//FIXME@extern void () break;
/*
abort (in QuakeC, this was break)
Tell the engine to abort (stop) code processing.
*/
@extern void () abort;
/*
error
Abort (crash) the server. "e" is the message the server crashes with.
*/
@extern void (string e) error;
/*
objerror
Prints info on the "self" ENTITY (not object), and error message "e".
The entity is freed.
*/
@extern void (string e) objerror;
/*
dprint
Print string "e" if the developer Cvar is set to a nonzero value
*/
@extern void (string s) dprint;
/*
coredump
Tell the engine to print all edicts (entities)
*/
@extern void () coredump;
/*
traceon
Enable instruction trace in the interpreter
*/
@extern void () traceon;
/*
traceoff
Disable instruction trace in the interpreter
*/
@extern void () traceoff;
/*
eprint
Print all information on an entity to the server console
*/
@extern void (entity e) eprint;
#endif //__ruamoko_debug_h

View File

@ -1,7 +1,7 @@
#ifndef __ruamoko_draw_h
#define __ruamoko_draw_h
#include "object.h"
#include "Object.h"
struct _qpic_t = {
integer width;

View File

@ -0,0 +1,84 @@
/*
entities.h
Entity function prototypes
Copyright (C) 2002 Bill Currie <taniwha@quakeforge.net>
Copyright (C) 2002 Jeff Teunissen <deek@quakeforge.net>
This file is part of the Ruamoko Standard Library.
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 program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __ruamoko_entities_h
#define __ruamoko_entities_h
/*
setmodel
Sets the model name for entity e to string m.
Set the entity's move type and solid type before calling this.
*/
@extern void (entity e, string m) setmodel;
/*
setorigin
Sets origin for entity e to vector o.
*/
@extern void (entity e, vector o) setorigin;
/*
setsize
Set the size of entity e to a cube with the bounds ( x1 y1 z1 ) ( x2 y2 z2 )
*/
@extern void (entity e, vector min, vector max) setsize;
/*
spawn
Creates a new entity and returns it.
*/
@extern entity () spawn;
/*
remove
Remove entity e.
*/
@extern void (entity e) remove;
@extern entity (entity start, .string fld, string match) find;
@extern entity (vector org, float rad) findradius;
@extern entity (entity e) nextent;
/*
makestatic
Make entity e static (part of the world).
Static entities do not interact with the game.
*/
@extern void (entity e) makestatic;
@extern void (entity e) setspawnparms;
#endif //__ruamoko_entities_h

View File

@ -1,30 +0,0 @@
#ifndef __ruamoko_entity_h
#define __ruamoko_entity_h
#include "object.h"
@interface Entity : Object
{
entity ent;
}
-init;
-initWithEntity:(entity)e;
-free;
-(entity)new;
-(entity)ent;
@end
@extern void (entity e, vector o) setorigin;
@extern void (entity e, string m) setmodel;
@extern void (entity e, vector min, vector max) setsize;
@extern entity () spawn;
@extern void (entity e) remove;
@extern entity (entity start, .string fld, string match) find;
@extern entity (vector org, float rad) findradius;
@extern entity (entity e) nextent;
@extern void (entity e) makestatic;
@extern void (entity e) setspawnparms;
#endif//__ruamoko_entity_h

View File

@ -1,19 +1,126 @@
/*
math.h
Built-in math function definitions
Copyright (C) 2002 Bill Currie <taniwha@quakeforge.net>
Copyright (C) 2002 Jeff Teunissen <deek@quakeforge.net>
This file is part of the Ruamoko Standard Library.
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 program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#ifndef __ruamoko_math_h
#define __ruamoko_math_h
/*
random
Generate a random number such that 0 <= num <= 1 (0 to 1 inclusive)
*/
@extern float () random;
/*
ftoi
Returns the integer component of f
*/
@extern integer (float f) ftoi;
/*
itof
Returns the float representation of i
*/
@extern float (integer i) itof;
/*
rint
Rounds v to the nearest integer value and returns it.
rint() does not change the type.
*/
@extern float (float v) rint;
/*
floor
Returns v, rounded down to the next lower integer
*/
@extern float (float v) floor;
/*
ceil
Returns v, rounded up to the next highest integer
*/
@extern float (float v) ceil;
/*
fabs
Returns the absolute value of v
*/
@extern float (float f) fabs;
/****************************************************************************
* VECTORS *
****************************************************************************/
@extern vector v_forward, v_up, v_right;
/*
makevectors
Set v_forward, v_up, v_right global vectors from the vector ang
*/
@extern void (vector ang) makevectors;
@extern float () random;
@extern integer (float f) ftoi;
@extern float (integer i) itof;
/*
normalize
Transform vector v into a unit vector (a vector with a length of 1).
The direction is not changed, except for (possible) roundoff errors.
*/
@extern vector (vector v) normalize;
/*
vlen
Return the length of vector v
*/
@extern float (vector v) vlen;
/*
vectoyaw
Returns the yaw angle ("bearing"), in degrees, associated with vector v.
*/
@extern float (vector v) vectoyaw;
@extern float (float v) rint;
@extern float (float v) floor;
@extern float (float v) ceil;
@extern float (float f) fabs;
/*
vectoangles
Returns a vector 'pitch yaw 0' corresponding to vector v.
*/
@extern vector (vector v) vectoangles;
#endif //__ruamoko_math_h

View File

@ -1,17 +0,0 @@
#ifndef __ruamoko_point_h
#define __ruamoko_point_h
#include "object.h"
@interface Point : Object
{
@public
integer x,y;
}
-initAtX:(integer)_x Y:(integer)_y;
-initWithPoint:(Point)p;
-setTo:(Point)p;
-moveBy:(Point)p;
@end
#endif//__ruamoko_point_h

28
ruamoko/lib/Entity.r Normal file
View File

@ -0,0 +1,28 @@
#include "Entity.h"
@implementation Entity
- (id) init
{
return [self initWithEntity: spawn ()];
}
- (id) initWithEntity: (entity)e
{
ent = e;
ent.@this = self;
return self;
}
- (void) free
{
remove (ent);
[super free];
}
- (entity) ent
{
return self.ent;
}
@end

View File

@ -1,4 +1,4 @@
#include "inputline.h"
#include "InputLine.h"
inputline_t (integer lines, integer size, integer prompt) InputLine_Create = #0;
void (inputline_t il, void [] data) InputLine_SetUserData = 0;
@ -16,50 +16,49 @@ string (inputline_t il) InputLine_GetText = #0;
@implementation InputLine
-free
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char
{
[at free];
id (self) = [super init];
id (frame) = [aRect copy];
il = InputLine_Create (frame.size.height, frame.size.width, char);
InputLine_SetUserData (il, frame);
return self;
}
- (void) free
{
[frame free];
InputLine_Destroy (il);
return [super free];
[super free];
}
-initAt:(Point)p HistoryLines:(integer)l LineSize:(integer)s PromptChar:(integer)prompt
- (void) setWidth: (integer)visibleWidth
{
[super init];
id(at) = [[Point alloc] initWithPoint:p];
il = InputLine_Create (l, s, prompt);
InputLine_SetUserData (il, at);
return self;
InputLine_SetWidth (il, width);
}
-setWidth:(integer)visibleWidth
{
InputLine_SetWidth (il, visibleWidth);
return self;
}
-process:(integer)key
- (void) processInput: (integer)key
{
InputLine_Process (il, key);
return self;
}
-draw:(BOOL)cursor
- (void) draw: (BOOL)cursor
{
#ifdef OLD_API
InputLine_Draw (il, at.x, at.y, cursor);
InputLine_Draw (il, frame.origin.x, frame.origin.y, cursor);
#else
InputLine_Draw (il, cursor);
#endif
}
-setText:(string)text
- (void) setText: (string)text
{
InputLine_SetText (il, text);
return self;
}
-(string)getText
- (string) text
{
return InputLine_GetText (il);
}

View File

@ -16,15 +16,14 @@ noinst_LIBRARIES= libr.a libgui.a libcsqc.a
%.o: %.r
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -p $(STRIP) -c -o $@ $<
libr_a_SOURCES=\
crudefile.r debug.r entity.r infokey.r math.r message.r nq_message.r \
object.r physics.r qw_message.r qw_physics.r qw_sys.r sound.r \
string.r system.r
crudefile.r debug.r entities.r infokey.r math.r message.r nq_message.r \
physics.r qw_message.r qw_physics.r qw_sys.r sound.r string.r system.r \
Object.r Entity.r
libr_a_AR=$(PAK) -cf
libgui_a_SOURCES=\
draw.r inputline.r key.r point.r
draw.r InputLine.r key.r Point.r
libgui_a_AR=$(PAK) -cf
libcsqc_a_SOURCES= \

View File

@ -1,4 +1,4 @@
#include "object.h"
#include "Object.h"
void (obj_module_t [] msg) __obj_exec_class = #0;
void (id object, integer code, string fmt, ...) obj_error = #0;

64
ruamoko/lib/Point.r Normal file
View File

@ -0,0 +1,64 @@
#include "Point.h"
@implementation Point
- (id) initWithComponents: (integer)_x : (integer)_y
{
id (self) = [super init];
x = _x;
y = _y;
return self;
}
- (id) initWithPoint: (Point) aPoint
{
id (self) = [super init];
if (!self || !aPoint)
return NIL;
x = [aPoint x];
y = [aPoint y];
return self;
}
- (id) copy
{
local id myCopy = [super copy];
if (!myCopy)
myCopy = [[self class] alloc];
return [myCopy initWithComponents: x : y];
}
- (id) x
{
return x;
}
- (id) y
{
return y;
}
- (void) setPoint: (Point)aPoint
{
x = [aPoint x];
y = [aPoint y];
}
- (void) addPoint: (Point) aPoint
{
x += [aPoint x];
y += [aPoint y];
}
- (void) subtractPoint: (Point) aPoint
{
x -= [aPoint x];
y -= [aPoint y];
}
@end

View File

@ -61,11 +61,6 @@ void (integer x, integer y, integer width, integer lines) text_box =
@implementation QPic
-initName:(string)n
{
return [self initName:n Centered:NO];
}
-initName:(string)n Centered:(BOOL)c
{
[super init];
@ -76,6 +71,11 @@ void (integer x, integer y, integer width, integer lines) text_box =
return self;
}
-initName:(string)n
{
return [self initName:n Centered:NO];
}
-draw:(integer)x :(integer)y
{
local qpic_t pic = Draw_CachePic (name, 1);

View File

@ -1,4 +1,4 @@
#include "entity.h"
#include "entities.h"
void (entity e, vector o) setorigin = #2;
void (entity e, string m) setmodel = #3;
@ -10,33 +10,3 @@ entity (vector org, float rad) findradius = #22;
entity (entity e) nextent = #47;
void (entity e) makestatic = #69;
void (entity e) setspawnparms = #78;
@implementation Entity
-init
{
return [self initWithEntity:[self new]];
}
-initWithEntity:(entity)e
{
self.ent = e;
e.@this = self;
return self;
}
-free
{
remove (self.ent);
return [super free];
}
-new
{
return spawn ();
}
-ent
{
return self.ent;
}
@end

View File

@ -1,33 +0,0 @@
#include "point.h"
@implementation Point
-initAtX:(integer)_x Y:(integer)_y
{
[super init];
x = _x;
y = _y;
return self;
}
-initWithPoint:(Point)p
{
[super init];
x = p.x;
y = p.y;
return self;
}
-setTo:(Point)p
{
x = p.x;
y = p.y;
return self;
}
-moveBy:(Point)p
{
x += p.x;
y += p.y;
return self;
}