Ejemplo n.º 1
0
void
RandomBoard (Board	b)
{
    short   board_order[4];
    Object  robot_order[4];
    Object  robot;
    short   i, j;

    for (j = 0; j < BOARD_HEIGHT; j++)
        for (i = 0; i < BOARD_WIDTH; i++)
            b[i][j] = 0;
    for (i = 0; i < 4; i++)
        board_order[i] = i;
    Shuffle (board_order, 4);
    for (i = 0; i < 4; i++)
    {
        ObjectLoc   l;

        j = Random(2);
        PlaceObjects (b, &Locations[board_order[i]][j],
                      aligns[i].rot,
                      aligns[i].dx,
                      aligns[i].dy);
        /*
         * Center walls
         */
        l.object = WALL_BELOW|WALL_RIGHT;
        l.x = 0;
        l.y = 0;
        PlaceObject (b, l,
                     aligns[i].rot,
                     aligns[i].dx,
                     aligns[i].dy);
    }

    robot = ROBOT_RED;
    for (i = 0; i < 4; i++)
    {
        robot_order[i] = robot;
        robot = ROBOT_NEXT(robot);
    }
    Shuffle ((short *) robot_order, 4);
    for (i = 0; i < 4; i++)
    {
        ObjectLoc   l;

        l.object = robot_order[i];
        l.x = Random (8);
        l.y = Random (8);
        PlaceObject (b, l, aligns[i].rot,
                     aligns[i].dx,
                     aligns[i].dy);
    }

#if BOARD_WIDTH != BOARD_HEIGHT
    %%%% assume square board
Ejemplo n.º 2
0
void DisplayList::UpdateButton(SObject* obj, int newState)
// Add or remove child characters so that the button matches newState
{
	SCharacter* ch = obj->character;
	if ( ch->type != buttonChar )
		return;
	
	int oldState = obj->state;
	if ( oldState == newState ) return;

	U8 * cxData = ch->button.cxformData;

	ScriptPlayer* player = ch->player;
	for ( int pass = 0; pass < 2; pass++ ) {
		SParser parser;
		parser.Attach(ch->data, 0);

		if ( ch->tagCode == stagDefineButton2 ) 
			parser.GetWord();	// skip the action offset

		SParser cxParser;
		if ( cxData )
			cxParser.Attach(cxData, 0);

		for (;;) {
			U8 stateFlags = parser.GetByte();
			if ( !stateFlags ) break;

			PlaceInfo info;
			info.flags = splaceCharacter|splaceMatrix|splaceColorTransform;
			U16 tag = parser.GetWord();
			info.depth = obj->depth + parser.GetWord();
			parser.GetMatrix(&info.mat);
			if ( ch->tagCode == stagDefineButton2 ) 
				parser.GetColorTransform(&info.cxform, true);	// new style button
			else if ( cxData )
				cxParser.GetColorTransform(&info.cxform, false);// separate cxfrom data
			else
				info.cxform.Clear();							// no cxform data

			// Remove the objects first and then add in case we have conflicting layer/id combos
			BOOL newVis = stateFlags & btnStateMap[newState];
			BOOL oldVis = stateFlags & btnStateMap[oldState];
			if ( pass == 0 && !newVis && oldVis ) {
				// Remove the child
				RemoveObject(obj, info.depth);
			}
			if ( pass == 1 && newVis && !oldVis ) {
				// Add the child
				info.character = player->FindCharacter(tag);
				info.name = 0;
				if ( info.character )
					PlaceObject(obj, &info);
			}
		}
	}
	obj->state = newState;
}
Ejemplo n.º 3
0
static void
PlaceObjects (Board	    b,
              ObjectLocs    *o,
              int	    rot,
              int	    dx,
              int	    dy)
{
    int		i;

    for (i = 0; i < o->nobj; i++)
        PlaceObject (b, o->obj[i], rot, dx, dy);
}
Ejemplo n.º 4
0
static int handle_number(void *ctx, const char *value, unsigned int length)
{
    _YajlDecoder *self = (_YajlDecoder *)(ctx);
    PyObject *object;
#ifdef IS_PYTHON3
    PyBytesObject *string;
#else
    PyObject *string;
#endif

    int floaty_char;

    // take a moment here to scan the input string to see if there's
    // any chars which suggest this is a floating point number
    for (floaty_char = 0; floaty_char < length; floaty_char++) {
        switch (value[floaty_char]) {
            case '.': case 'e': case 'E': goto floatin;
        }
    }

  floatin:
#ifdef IS_PYTHON3
    string = (PyBytesObject *)PyBytes_FromStringAndSize(value, length);
    if (floaty_char >= length) {
        object = PyLong_FromString(string->ob_sval, NULL, 10);
    } else {
        object = PyFloat_FromString((PyObject *)string);
    }
#else
    string = PyString_FromStringAndSize(value, length);
    if (floaty_char >= length) {
        object = PyInt_FromString(PyString_AS_STRING(string), NULL, 10);
    } else {
        object = PyFloat_FromString(string, NULL);
    }
#endif
    Py_XDECREF(string);
    return PlaceObject(self, object);
}
Ejemplo n.º 5
0
static int handle_bool(void *ctx, int value)
{
    return PlaceObject(ctx, PyBool_FromLong((long)(value)));
}
Ejemplo n.º 6
0
static int handle_null(void *ctx)
{
    Py_INCREF(Py_None);
    return PlaceObject(ctx, Py_None);
}
Ejemplo n.º 7
0
static int handle_string(void *ctx, const unsigned char *value, unsigned int length)
{
    return PlaceObject(ctx, PyUnicode_FromStringAndSize((char *)value, length));
}
void KeyboardBehaviour::update(float step)
{
    PlaceObject();
    PickUpObject();
}