Created
May 9, 2012 21:10
-
-
Save mkosler/2648855 to your computer and use it in GitHub Desktop.
The CPP source file of a Puzzle League block when built with Haxe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hxcpp.h> | |
#ifndef INCLUDED_hxMath | |
#include <hxMath.h> | |
#endif | |
#ifndef INCLUDED_com_haxepunk_Entity | |
#include <com/haxepunk/Entity.h> | |
#endif | |
#ifndef INCLUDED_com_haxepunk_Graphic | |
#include <com/haxepunk/Graphic.h> | |
#endif | |
#ifndef INCLUDED_com_haxepunk_Mask | |
#include <com/haxepunk/Mask.h> | |
#endif | |
#ifndef INCLUDED_com_haxepunk_Tweener | |
#include <com/haxepunk/Tweener.h> | |
#endif | |
#ifndef INCLUDED_com_haxepunk_graphics_Image | |
#include <com/haxepunk/graphics/Image.h> | |
#endif | |
#ifndef INCLUDED_entities_play_Block | |
#include <entities/play/Block.h> | |
#endif | |
#ifndef INCLUDED_entities_play_Grid | |
#include <entities/play/Grid.h> | |
#endif | |
#ifndef INCLUDED_neash_geom_Rectangle | |
#include <neash/geom/Rectangle.h> | |
#endif | |
namespace entities{ | |
namespace play{ | |
Void Block_obj::__construct(double p_x,double p_y,int p_size,::entities::play::Grid p_grid) | |
{ | |
{ | |
HX_SOURCE_POS("src/entities/play/Block.hx",28) | |
super::__construct(p_x,p_y,null(),null()); | |
HX_SOURCE_POS("src/entities/play/Block.hx",30) | |
this->color = Array_obj< ::String >::__new().Add(HX_CSTRING("red")).Add(HX_CSTRING("blue")).Add(HX_CSTRING("cyan")).Add(HX_CSTRING("magenta")).Add(HX_CSTRING("yellow")).Add(HX_CSTRING("green"))->__get(::Math_obj::round((::Math_obj::random() * ((Array_obj< ::String >::__new().Add(HX_CSTRING("red")).Add(HX_CSTRING("blue")).Add(HX_CSTRING("cyan")).Add(HX_CSTRING("magenta")).Add(HX_CSTRING("yellow")).Add(HX_CSTRING("green"))->length - (int)1))))); | |
HX_SOURCE_POS("src/entities/play/Block.hx",36) | |
this->setGraphic(::com::haxepunk::graphics::Image_obj::__new(((HX_CSTRING("gfx/blocks/block-") + this->color) + HX_CSTRING(".png")),null(),null())); | |
HX_SOURCE_POS("src/entities/play/Block.hx",38) | |
{ | |
HX_SOURCE_POS("src/entities/play/Block.hx",38) | |
this->width = p_size; | |
HX_SOURCE_POS("src/entities/play/Block.hx",38) | |
this->height = p_size; | |
HX_SOURCE_POS("src/entities/play/Block.hx",38) | |
this->originX = (int)0; | |
HX_SOURCE_POS("src/entities/play/Block.hx",38) | |
this->originY = (int)0; | |
} | |
HX_SOURCE_POS("src/entities/play/Block.hx",39) | |
this->setType(HX_CSTRING("block")); | |
HX_SOURCE_POS("src/entities/play/Block.hx",41) | |
this->_grid = p_grid; | |
HX_SOURCE_POS("src/entities/play/Block.hx",43) | |
this->oldX = this->x; | |
HX_SOURCE_POS("src/entities/play/Block.hx",44) | |
this->oldY = this->y; | |
} | |
; | |
return null(); | |
} | |
Block_obj::~Block_obj() { } | |
Dynamic Block_obj::__CreateEmpty() { return new Block_obj; } | |
hx::ObjectPtr< Block_obj > Block_obj::__new(double p_x,double p_y,int p_size,::entities::play::Grid p_grid) | |
{ hx::ObjectPtr< Block_obj > result = new Block_obj(); | |
result->__construct(p_x,p_y,p_size,p_grid); | |
return result;} | |
Dynamic Block_obj::__Create(hx::DynamicArray inArgs) | |
{ hx::ObjectPtr< Block_obj > result = new Block_obj(); | |
result->__construct(inArgs[0],inArgs[1],inArgs[2],inArgs[3]); | |
return result;} | |
Void Block_obj::update( ){ | |
{ | |
HX_SOURCE_PUSH("Block_obj::update") | |
HX_SOURCE_POS("src/entities/play/Block.hx",49) | |
this->super::update(); | |
HX_SOURCE_POS("src/entities/play/Block.hx",51) | |
this->oldX = this->x; | |
HX_SOURCE_POS("src/entities/play/Block.hx",52) | |
this->oldY = this->y; | |
HX_SOURCE_POS("src/entities/play/Block.hx",53) | |
this->moveBy((int)0,(int)5,Array_obj< ::String >::__new().Add(HX_CSTRING("block")).Add(HX_CSTRING("wall")),null()); | |
HX_SOURCE_POS("src/entities/play/Block.hx",54) | |
if (((bool((this->x != this->oldX)) || bool((this->y != this->oldY))))){ | |
HX_SOURCE_POS("src/entities/play/Block.hx",54) | |
this->setGridLocation(); | |
} | |
} | |
return null(); | |
} | |
::entities::play::Block Block_obj::setGridLocation( ){ | |
HX_SOURCE_PUSH("Block_obj::setGridLocation") | |
HX_SOURCE_POS("src/entities/play/Block.hx",61) | |
this->_grid->releaseBlock(hx::ObjectPtr<OBJ_>(this)); | |
HX_SOURCE_POS("src/entities/play/Block.hx",62) | |
return this->_grid->attachBlock(hx::ObjectPtr<OBJ_>(this)); | |
} | |
HX_DEFINE_DYNAMIC_FUNC0(Block_obj,setGridLocation,return ) | |
Array< ::String > Block_obj::colors; | |
int Block_obj::_speed; | |
Block_obj::Block_obj() | |
{ | |
} | |
void Block_obj::__Mark(HX_MARK_PARAMS) | |
{ | |
HX_MARK_BEGIN_CLASS(Block); | |
HX_MARK_MEMBER_NAME(color,"color"); | |
HX_MARK_MEMBER_NAME(oldX,"oldX"); | |
HX_MARK_MEMBER_NAME(oldY,"oldY"); | |
HX_MARK_MEMBER_NAME(_grid,"_grid"); | |
super::__Mark(HX_MARK_ARG); | |
HX_MARK_END_CLASS(); | |
} | |
Dynamic Block_obj::__Field(const ::String &inName,bool inCallProp) | |
{ | |
switch(inName.length) { | |
case 4: | |
if (HX_FIELD_EQ(inName,"oldX") ) { return oldX; } | |
if (HX_FIELD_EQ(inName,"oldY") ) { return oldY; } | |
break; | |
case 5: | |
if (HX_FIELD_EQ(inName,"color") ) { return color; } | |
if (HX_FIELD_EQ(inName,"_grid") ) { return _grid; } | |
break; | |
case 6: | |
if (HX_FIELD_EQ(inName,"colors") ) { return colors; } | |
if (HX_FIELD_EQ(inName,"_speed") ) { return _speed; } | |
if (HX_FIELD_EQ(inName,"update") ) { return update_dyn(); } | |
break; | |
case 15: | |
if (HX_FIELD_EQ(inName,"setGridLocation") ) { return setGridLocation_dyn(); } | |
} | |
return super::__Field(inName,inCallProp); | |
} | |
Dynamic Block_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp) | |
{ | |
switch(inName.length) { | |
case 4: | |
if (HX_FIELD_EQ(inName,"oldX") ) { oldX=inValue.Cast< double >(); return inValue; } | |
if (HX_FIELD_EQ(inName,"oldY") ) { oldY=inValue.Cast< double >(); return inValue; } | |
break; | |
case 5: | |
if (HX_FIELD_EQ(inName,"color") ) { color=inValue.Cast< ::String >(); return inValue; } | |
if (HX_FIELD_EQ(inName,"_grid") ) { _grid=inValue.Cast< ::entities::play::Grid >(); return inValue; } | |
break; | |
case 6: | |
if (HX_FIELD_EQ(inName,"colors") ) { colors=inValue.Cast< Array< ::String > >(); return inValue; } | |
if (HX_FIELD_EQ(inName,"_speed") ) { _speed=inValue.Cast< int >(); return inValue; } | |
} | |
return super::__SetField(inName,inValue,inCallProp); | |
} | |
void Block_obj::__GetFields(Array< ::String> &outFields) | |
{ | |
outFields->push(HX_CSTRING("color")); | |
outFields->push(HX_CSTRING("oldX")); | |
outFields->push(HX_CSTRING("oldY")); | |
outFields->push(HX_CSTRING("_grid")); | |
super::__GetFields(outFields); | |
}; | |
static ::String sStaticFields[] = { | |
HX_CSTRING("colors"), | |
HX_CSTRING("_speed"), | |
String(null()) }; | |
static ::String sMemberFields[] = { | |
HX_CSTRING("color"), | |
HX_CSTRING("oldX"), | |
HX_CSTRING("oldY"), | |
HX_CSTRING("_grid"), | |
HX_CSTRING("update"), | |
HX_CSTRING("setGridLocation"), | |
String(null()) }; | |
static void sMarkStatics(HX_MARK_PARAMS) { | |
HX_MARK_MEMBER_NAME(Block_obj::colors,"colors"); | |
HX_MARK_MEMBER_NAME(Block_obj::_speed,"_speed"); | |
}; | |
Class Block_obj::__mClass; | |
void Block_obj::__register() | |
{ | |
Static(__mClass) = hx::RegisterClass(HX_CSTRING("entities.play.Block"), hx::TCanCast< Block_obj> ,sStaticFields,sMemberFields, | |
&__CreateEmpty, &__Create, | |
&super::__SGetClass(), 0, sMarkStatics); | |
} | |
void Block_obj::__boot() | |
{ | |
hx::Static(colors) = Array_obj< ::String >::__new().Add(HX_CSTRING("red")).Add(HX_CSTRING("blue")).Add(HX_CSTRING("cyan")).Add(HX_CSTRING("magenta")).Add(HX_CSTRING("yellow")).Add(HX_CSTRING("green")); | |
hx::Static(_speed) = (int)5; | |
} | |
} // end namespace entities | |
} // end namespace play |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment