Exemplo n.º 1
0
void defineScrolling()
{
   VALUE cScroll = defClass<Scrolling>("Scrolling", "Drawable");
   defMethod(cScroll, "initialize", Scrolling_initialize, -1);

   defMethod(cScroll, "setSprite", Scrolling_setSprite, 1);
   defMethod(cScroll, "setDir", Scrolling_setDir, 1);
   defMethod(cScroll, "setSpeed", Scrolling_setSpeed, 1);
   defMethod(cScroll, "dir", Scrolling_dir, 0);
   defMethod(cScroll, "speed", Scrolling_speed, 0); 
   defMethod(cScroll, "play", Scrolling_play, 0);

   defAlias(cScroll, "setSprite", "sprite=");
   defAlias(cScroll, "setDir", "dir=");
   defAlias(cScroll, "dir", "direction");
   defAlias(cScroll, "setDir", "direction=");
   defAlias(cScroll, "setSpeed", "speed=");

   defConst(cScroll, "LEFT", INT2FIX(Sprite::LEFT));
   defConst(cScroll, "RIGHT", INT2FIX(Sprite::RIGHT));
   defConst(cScroll, "UP", INT2FIX(Sprite::UP));
   defConst(cScroll, "DOWN", INT2FIX(Sprite::DOWN));
}
Exemplo n.º 2
0
void defineGameMap()
{
   VALUE cCollisionType = defClass<CollisionType>("CollisionType");
   defMethod(cCollisionType, "initialize", CollisionType_initialize, -1);

   defMethod(cCollisionType, "left", CollisionType_left, 0);
   defMethod(cCollisionType, "right", CollisionType_right, 0);
   defMethod(cCollisionType, "up", CollisionType_up, 0);
   defMethod(cCollisionType, "down", CollisionType_down, 0);
   defMethod(cCollisionType, "content", CollisionType_content, 0);

   defMethod(cCollisionType, "left=", CollisionType_setLeft, 1);
   defMethod(cCollisionType, "right=", CollisionType_setRight, 1);
   defMethod(cCollisionType, "up=", CollisionType_setUp, 1);
   defMethod(cCollisionType, "down=", CollisionType_setDown, 1);
   defMethod(cCollisionType, "content=", CollisionType_setContent, 1);
   
   VALUE cTile = defClass<GameMap::Tile>("Tile");
   defMethod(cTile, "initialize", GameMap_Tile_initialize, -1);

   defMethod(cTile, "x", Tile_x, 0);
   defMethod(cTile, "y", Tile_y, 0);
   defMethod(cTile, "tileset", Tile_tileset, 0);
   defMethod(cTile, "tileX", Tile_tileX, 0);
   defMethod(cTile, "tileY", Tile_tileY, 0);
   defMethod(cTile, "type", Tile_type, 0);

   defMethod(cTile, "x=", Tile_setX, 1);
   defMethod(cTile, "y=", Tile_setY, 1);
   defMethod(cTile, "tileset=", Tile_setTileset, 1);
   defMethod(cTile, "tileX=", Tile_setTileX, 1);
   defMethod(cTile, "tileY=", Tile_setTileY, 1);
   defMethod(cTile, "type=", Tile_setType, 1);
 
   VALUE cMap = defClass<GameMap>("GameMap", "Drawable");
   defMethod(cMap, "initialize", GameMap_initialize, -1);

   defMethod(cMap, "addTileset", GameMap_addTileset, 1);
   defMethod(cMap, "setTileSize", GameMap_setTileSize, 2);
   defMethod(cMap, "tileWidth", GameMap_tileWidth, 0);
   defMethod(cMap, "tileHeight", GameMap_tileHeight, 0);
   defMethod(cMap, "collisionH=", GameMap_setCollisionH, 1);
   defMethod(cMap, "collisionH", GameMap_collisionH, 0);
   defMethod(cMap, "absToRel", GameMap_absToRel, 2);
   defMethod(cMap, "relToAbs", GameMap_relToAbs, 2);
   defMethod(cMap, "centerOn", GameMap_centerOn, 2);
   defMethod(cMap, "addElem", GameMap_addElem, -1);
   defMethod(cMap, "<<", GameMap_push, 1);
   defMethod(cMap, "clear", GameMap_clear, 0);
   defMethod(cMap, "clearTiles", GameMap_clearTiles, 0);
   defMethod(cMap, "clear_between", GameMap_clearBetween, 0);
   defMethod(cMap, "tiles", GameMap_tiles, 0);
   defMethod(cMap, "tilesets", GameMap_tilesets, 0);
   defMethod(cMap, "each_tile", GameMap_each_tile, 0);
   defMethod(cMap, "each_tileset", GameMap_each_tileset, 0);
   defMethod(cMap, "reject_tiles", GameMap_reject_tiles, 0);
   defMethod(cMap, "addBetween", GameMap_addBetween, 1);

   defAlias(cMap, "addTileset", "add_tileset");
   defAlias(cMap, "setTileSize", "set_tile_size");
   defAlias(cMap, "tileWidth", "tile_width");
   defAlias(cMap, "tileHeight", "tile_height");
   defAlias(cMap, "collisionH", "collision_h");
   defAlias(cMap, "collisionH=", "collision_h=");
   defAlias(cMap, "absToRel", "abs2rel");
   defAlias(cMap, "relToAbs", "rel2abs");
   defAlias(cMap, "centerOn", "center_on");
   defAlias(cMap, "addElem", "add_elem");
   defAlias(cMap, "clearTiles", "clear_tiles");

   CollisionType full(true, false, false, false, false);
   CollisionType left(false, true, false, false, false);
   CollisionType right(false, false, true, false, false);
   CollisionType up(false, false, false, true, false);
   CollisionType down(false, false, false, false, true);
   CollisionType no(false, false, false, false, false);
   CollisionType left_right(false, true, true, false, false);
   CollisionType left_up(false, true, false, true, false);
   CollisionType left_down(false, true, false, false, true);
   CollisionType right_up(false, false, true, true, false);
   CollisionType right_down(false, false, true, false, true);
   CollisionType up_down(false, false, false, true, true);

   /*
     Document-const: COL_FULL
     Joyau::CollisionType.new(true, false, false, false, false): Collision with
     everything.
   */

   /*
     Document-const: COL_LEFT
     Joyau::CollisionType.new(false, true, false, false, false): Collision with
     the left side.
   */

   /*
     Document-const: COL_RIGHT
     Joyau::CollisionType.new(false, false, true, false, false): Collision with
     the right side.
   */

   /*
     Document-const: COL_UP
     Joyau::CollisionType.new(false, false, false, true, false): Collision with
     the upper side.
   */

   /*
     Document-const: COL_DOWN
     Joyau::CollisionType.new(false, false, false, false, true): Collision with
     the downer side.
   */

   /*
     Document-const: COL_NO
     Joyau::CollisionType.new(false, false, false, false, false): Collision 
     with nothing.
   */

   /*
     Document-const: COL_LEFT_RIGHT
     Joyau::CollisionType.new(false, true, true, false, false): Collision with
     the left and right sides.
   */

   /*
     Document-const: COL_LEFT_UP
     Joyau::CollisionType.new(false, true, false, true, false): Collision with
     the left and the upper sides.
   */

   /*
     Document-const: COL_LEFT_DOWN
     Joyau::CollisionType.new(false, true, false, false, true): Collision with
     the left and the downer sides.
   */

   /*
     Document-const: COL_RIGHT_UP
     Joyau::CollisionType.new(false, false, true, true, false): Collision with
     the right and the upper sides.
   */

   /*
     Document-const: COL_RIGHT_DOWN
     Joyau::CollisionType.new(false, false, true, false, true): Collision with
     the right and the downer sides.
   */

   /*
     Document-const: COL_UP_DOWN
     Joyau::CollisionType.new(false, false, false, true, true): Collision with
     the upper and the downer sides.
   */


   defConst(cMap, "COL_FULL", createObject(cCollisionType, full));
   defConst(cMap, "COL_LEFT", createObject(cCollisionType, left));
   defConst(cMap, "COL_RIGHT", createObject(cCollisionType, right));
   defConst(cMap, "COL_UP", createObject(cCollisionType, up));
   defConst(cMap, "COL_DOWN", createObject(cCollisionType, down));
   defConst(cMap, "COL_NO", createObject(cCollisionType, no));
   defConst(cMap, "COL_LEFT_RIGHT", createObject(cCollisionType, left_right));
   defConst(cMap, "COL_LEFT_UP", createObject(cCollisionType, left_up));
   defConst(cMap, "COL_LEFT_DOWN", createObject(cCollisionType, left_down));
   defConst(cMap, "COL_RIGHT_UP", createObject(cCollisionType, right_up));
   defConst(cMap, "COL_RIGHT_DOWN", createObject(cCollisionType, right_down));
   defConst(cMap, "COL_UP_DOWN", createObject(cCollisionType, up_down));
}
Exemplo n.º 3
0
void defineBuffer() {
   VALUE cBuffer = defClass<Buffer>("Buffer");
   
   /* 
      Document-const: PF_4444      
      PF_4444: Pixel format for 8 bits colors.
   */
   
   /*
      Document-const: PF_5650   
      PF_5650: Pixel format for 16 bits colors.
   */
   
   /*
      Document-const: PF_8888   
      PF_8888: Pixel format for 32 bits colors.
   */

   defConst(cBuffer, "PF_4444", INT2FIX(OSL_PF_4444));
   defConst(cBuffer, "PF_5650", INT2FIX(OSL_PF_5650));
   defConst(cBuffer, "PF_8888", INT2FIX(OSL_PF_8888));
   
   defMethod(cBuffer, "initialize", Buffer_initialize, -1);

   defMethod(cBuffer, "set_actual", Buffer_setActual, 0);
   defMethod(cBuffer, "draw", Buffer_draw, -1);
   defMethod(cBuffer, "clear", Buffer_clear, 1);
   defMethod(cBuffer, "x", Buffer_getX, 0);
   defMethod(cBuffer, "y", Buffer_getY, 0);
   defMethod(cBuffer, "w", Buffer_getW, 0);
   defMethod(cBuffer, "h", Buffer_getH, 0);
   defMethod(cBuffer, "x=", Buffer_setX, 1);
   defMethod(cBuffer, "y=", Buffer_setY, 1);
   defMethod(cBuffer, "setPos", Buffer_setPos, -1);
   defMethod(cBuffer, "move", Buffer_move, 2);
   defMethod(cBuffer, "resize", Buffer_resize, 2);
   defMethod(cBuffer, "zoom", Buffer_zoom, 1);
   defMethod(cBuffer, "rotate", Buffer_rotate, 1);
   defMethod(cBuffer, "lock", Buffer_lock, -1);
   defMethod(cBuffer, "unlock", Buffer_unlock, 0);
   defMethod(cBuffer, "[]", Buffer_getPixel, 2);
   defMethod(cBuffer, "[]=", Buffer_setPixel, 3);
   defMethod(cBuffer, "save", Buffer_save, 1);
   defMethod(cBuffer, "to_sprite", Buffer_to_sprite, 0);
   
   defClassMethod(cBuffer, "screen", Buffer_getScreen, 0);
   defClassMethod(cBuffer, "default", Buffer_getDefault, 0);
   defClassMethod(cBuffer, "actual", Buffer_getActual, 0);

   defClassMethod(cBuffer, "[]", Buffer_find, -1);
   
   defAlias(cBuffer, "setPos", "pos=");

   VALUE cPainter = defClass<Painter>("Painter");
   defMethod(cPainter, "initialize", Painter_initialize, 1);

   defMethod(cPainter, "drawLine", Painter_drawLine, -1);
   defMethod(cPainter, "drawFillRect", Painter_drawFillRect, -1);
   defMethod(cPainter, "drawRect", Painter_drawRect, -1);
   defMethod(cPainter, "drawPoint", Painter_drawPoint, 3);
   defMethod(cPainter, "drawCircle", Painter_drawCircle, 4);
   defMethod(cPainter, "drawFillCircle", Painter_drawFillCircle, 4);
   defMethod(cPainter, "drawTriangle", Painter_drawTriangle, -1);
   defMethod(cPainter, "drawBuffer", Painter_drawBuffer, 3);
 
   defMethod(cPainter, "clear", Painter_clear, 1);
   
   VALUE joyau = JOYAU_MOD;
   defModFunc(joyau, "draw", Joyau_draw, -1);
}
Exemplo n.º 4
0
void defineKeys()
{
   VALUE keys = rb_hash_new();
   rb_gv_set("$keys", keys);

   VALUE joyau = JOYAU_MOD;
   defModFunc(joyau, "readKeys", checkKeys, 0);
   defModFunc(joyau, "gets", Joyau_gets, 0);

   VALUE mPad = defModule("Pad");
   defModFunc(mPad, "update", Pad_update, 0);
   defModFunc(mPad, "held?", Pad_held, 1);
   defModFunc(mPad, "pressed?", Pad_pressed, 1);
   defModFunc(mPad, "released?", Pad_released, 1);
   defModFunc(mPad, "stickX", Pad_stickX, 0);
   defModFunc(mPad, "stickY", Pad_stickY, 0);

   defConst(mPad, "SELECT", INT2FIX(PSP_CTRL_SELECT));
   defConst(mPad, "START", INT2FIX(PSP_CTRL_START));

   defConst(mPad, "L", INT2FIX(PSP_CTRL_LTRIGGER));
   defConst(mPad, "R", INT2FIX(PSP_CTRL_RTRIGGER));

   defConst(mPad, "CROSS", INT2FIX(PSP_CTRL_CROSS));
   defConst(mPad, "SQUARE", INT2FIX(PSP_CTRL_SQUARE));
   defConst(mPad, "TRIANGLE", INT2FIX(PSP_CTRL_TRIANGLE));
   defConst(mPad, "CIRCLE", INT2FIX(PSP_CTRL_CIRCLE));

   defConst(mPad, "UP", INT2FIX(PSP_CTRL_UP));
   defConst(mPad, "DOWN", INT2FIX(PSP_CTRL_DOWN));
   defConst(mPad, "LEFT", INT2FIX(PSP_CTRL_LEFT));
   defConst(mPad, "RIGHT", INT2FIX(PSP_CTRL_RIGHT));

   defConst(mPad, "HOLD", INT2FIX(PSP_CTRL_HOLD));

   /*
     Document-class: Joyau::OSK

     There is a built-in keyboard in your firmware, which can be used by your
     program easily through this class. Notice Joyau.gets is a simpliefied
     version of this module, which can handle more advanced settings.

     You can, by using its constants, specify what has to be input.
     you can indicated the used language:

     1. DEFAULT
     2. JAPANESE
     3. ENGLISH
     4. FRENCH
     5. SPANISH
     6. GERMAN
     7. ITALIAN
     8. DUTCH
     9. PORTUGESE
     10. RUSSIAN
     11. KOREAN

     As well as the caracters to input:
     
     1. ALL
     2. LATIN_SYMBOL
     3. LATIN_LOWERCASE
     4. LATIN_UPPERCASE
     5. LATIN_DIGIT
     6. JAPANESE_DIGIT
     7. JAPANESE_SYMBOL
     8. JAPANESE_LOWERCASE
     9. JAPANESE_UPPERCASE
     10. JAPANESE_HIRAGANA
     11. JAPANASE_HALF_KATAKANA
     12. JAPANESE_KATAKANA
     13. JAPANESE_LOWERCASE
     14. RUSSIAN_LOWERCASE
     15. RUSSIAN_UPPERCASE
     16. IT_KOREAN
     17. URL

     You can also set the default text and the description, and give a block
     telling what to draw under the keyboard (if nothing were drawn, there'd
     be graphical glitches).
   */
   VALUE mOSK = defModule("OSK");
   defModFunc(mOSK, "run", Osk_run, 5);
   
   defConst(mOSK, "DEFAULT", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_DEFAULT));
   defConst(mOSK, "JAPANESE", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_JAPANESE));
   defConst(mOSK, "ENGLISH", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_ENGLISH));
   defConst(mOSK, "FRENCH", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_SPANISH));
   defConst(mOSK, "SPANISH", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_SPANISH));
   defConst(mOSK, "GERMAN", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_GERMAN));
   defConst(mOSK, "ITALIAN", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_ITALIAN));
   defConst(mOSK, "PORTUGESE", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_PORTUGESE));
   defConst(mOSK, "RUSSIAN", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_RUSSIAN));
   defConst(mOSK, "KOREAN", INT2FIX(PSP_UTILITY_OSK_LANGUAGE_KOREAN));
   
   defConst(mOSK, "ALL", INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_ALL));
   defConst(mOSK, "LATIN_DIGIT", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT));
   defConst(mOSK, "LATIN_SYMBOL", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_LATIN_SYMBOL));
   defConst(mOSK, "LATIN_LOWERCASE", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_LATIN_LOWERCASE));
   defConst(mOSK, "LATIN_UPPERCASE", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_LATIN_UPPERCASE));
   defConst(mOSK, "JAPANESE_DIGIT", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_DIGIT));
   defConst(mOSK, "JAPANESE_SYMBOL", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_SYMBOL));
   defConst(mOSK, "JAPANESE_LOWERCASE", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_LOWERCASE));
   defConst(mOSK, "JAPANESE_UPPERCASE", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_UPPERCASE));
   defConst(mOSK, "JAPANESE_HIRAGANA", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HIRAGANA));
   defConst(mOSK, "JAPANASE_HALF_KATAKANA", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HALF_KATAKANA));
   defConst(mOSK, "JAPANESE_KATAKANA", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KATAKANA));
   defConst(mOSK, "RUSSIAN_LOWERCASE", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_LOWERCASE));
   defConst(mOSK, "RUSSIAN_UPPERCASE", 
	    INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_UPPERCASE));
   defConst(mOSK, "IT_KOREAN", INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_KOREAN));
   defConst(mOSK, "URL", INT2FIX(PSP_UTILITY_OSK_INPUTTYPE_URL));

   VALUE cCursor = defClass<Cursor>("Cursor", "Sprite");
   defMethod(cCursor, "updatePos", Cursor_updatePos, 0);

   defMethod(cCursor, "setSensibility", Cursor_setSensibility, 1);
   defMethod(cCursor, "sensibility", Cursor_sensibility, 0);

   defMethod(cCursor, "rect=", Cursor_setRect, 1);
   defMethod(cCursor, "rect", Cursor_rect, 0);

   defAlias(cCursor, "setSensibility", "sensibility=");
   defAlias(cCursor, "updatePos", "update_pos");
}