// SetupStage_Level1 // Set up the stage (sprites and backgrounds) for level 1. void GameState::SetupStage_Level1() { // Set the default sprite video mode. SetSpriteVideoMode(); // Setup the foreground sprites. // The sprite data is not active until we copy it from our data // tables (in sprites.cpp) into the real Palette and Graphics memory. // So, let's copy the default spriteset there now. ClearSprites(); LoadSpriteset(0); // Setup the background tiles and map. // Just like sprites, the data is not active until we copy it from // our data tables (in background_maps.cpp) into real memory. ClearBackgrounds(); LoadBgTileset(0); LoadBgMap(0); // Initialize the objects for the first level. InitObject(kObj_Player, kSprites_Player); InitObject(kObj_New, kSprites_New); // Set the initial location of each object. _xPlayer = 0; _yPlayer = 0; MoveObjectTo(kObj_Player, _xPlayer, _yPlayer); MoveObjectTo(kObj_New, 50, 50); // TODO: Add more initialization for level 1 here. }
/*********** core functions ***************/ void Model_Gameplay::Init() { /*** Stuff that need to always re-init here ***/ /*** Only init once stuff below here ***/ Model::Init(); /* Init local already? */ if( initLocalAlready ) //yes, init alr return; initLocalAlready = true; //no, then first time init //light lightPos[0].Set(1000.f, 500.f, 0.f); lightPos[1].Set(0.f, 800.f, 0.f); //weapon //Weapon::InitAmmo(elementObject); //object InitObject(); //player: last so will alpha all walls player.Init(Vector3(800, 800, 1), Vector3(230, 230, 1), Character::E, 100, 100, 350); elementObject.push_back(player.getObject()); /* Init all game objects */ for(std::vector<Object*>::iterator it = elementObject.begin(); it != elementObject.end(); ++it) { Object *go = (Object *)*it; go->Init(); } }
ShipCpanel::ShipCpanel(Graphics::Renderer *r): Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight())) { m_scanner = new ScannerWidget(r); InitObject(); }
/** * Creates a rectangle object of the given dimensions and returns * a pointer to the object. * @param hPal Palette for the rectangle object * @param color Which color offset from the above palette * @param width Width of rectangle * @param height Height of rectangle */ OBJECT *RectangleObject(SCNHANDLE hPal, int color, int width, int height) { // template for initialising the rectangle object static const OBJ_INIT rectObj = {0, DMA_CONST, OID_EFFECTS, 0, 0, 0}; PALQ *pPalQ; // palette queue pointer // allocate and init a new object OBJECT *pRect = InitObject(&rectObj); // allocate a palette for this object pPalQ = AllocPalette(hPal); // make sure palette allocated assert(pPalQ != NULL); // assign palette to object pRect->pPal = pPalQ; // set color in the palette pRect->constant = color; // set rectangle width pRect->width = width; // set rectangle height pRect->height = height; // return pointer to rectangle object return pRect; }
/* function to handle key press events */ void handleKeyPress( SDL_keysym *keysym ) { switch ( keysym->sym ) { case SDLK_ESCAPE: /* ESC key was pressed */ Quit( 0 ); break; case SDLK_F1: /* 'f' key was pressed * this toggles fullscreen mode */ SDL_WM_ToggleFullScreen( surface ); break; case SDLK_SPACE: if (game) // Space Bar Being Pressed After Game Has Ended? { for (int loop=0; loop<30; loop++) // Loop Through 30 Objects InitObject(loop); // Initialize Each Object game=false; // Set game (Game Over) To False score=0; // Set score To 0 level=1; // Set level Back To 1 kills=0; // Zero Player Kills miss=0; // Set miss (Missed Shots) To 0 } break; default: break; } return; }
/** * Initialise a multi-part object using a list of images to init * each object piece. One object is created for each image in the list. * All objects are given the same palette as the first image. A pointer * to the first (master) object created is returned. * @param pInitTbl Pointer to multi-object initialisation table */ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) { OBJ_INIT obj_init; // object init table OBJECT *pFirst, *pObj; // object pointers FRAME *pFrame; // list of images for the multi-part object if (FROM_LE_32(pInitTbl->hMulFrame)) { // we have a frame handle pFrame = (FRAME *)LockMem(FROM_LE_32(pInitTbl->hMulFrame)); obj_init.hObjImg = READ_LE_UINT32(pFrame); // first objects shape } else { // this must be a animation list for a NULL object pFrame = NULL; obj_init.hObjImg = 0; // first objects shape } // init the object init table obj_init.objFlags = (int)FROM_LE_32(pInitTbl->mulFlags); // all objects have same flags obj_init.objID = (int)FROM_LE_32(pInitTbl->mulID); // all objects have same ID obj_init.objX = (int)FROM_LE_32(pInitTbl->mulX); // all objects have same X ani pos obj_init.objY = (int)FROM_LE_32(pInitTbl->mulY); // all objects have same Y ani pos obj_init.objZ = (int)FROM_LE_32(pInitTbl->mulZ); // all objects have same Z pos // create and init the first object pObj = pFirst = InitObject(&obj_init); if (pFrame) { // if we have any animation frames pFrame++; while (READ_LE_UINT32(pFrame) != 0) { // set next objects shape obj_init.hObjImg = READ_LE_UINT32(pFrame); // create next object and link to previous pObj = pObj->pSlave = InitObject(&obj_init); pFrame++; } } // null end of list for final object pObj->pSlave = NULL; // return master object return pFirst; }
ShipCpanel::ShipCpanel(Serializer::Reader &rd, Graphics::Renderer *r): Gui::Fixed(float(Gui::Screen::GetWidth()), 80) { m_scanner = new ScannerWidget(r, rd); InitObject(); m_camButton->SetActiveState(rd.Int32()); }
MediaView::MediaView( BRect frame, const char *name, uint32 resizeMask, uint32 flags) : BView(frame, name, resizeMask, flags) { InitObject(); }
//! Copy&Paste error, should be removed at some point (already private) BMenuField::BMenuField(const char* label, BMenu* menu, BMessage* message) : BView(NULL, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS) { InitObject(label); _InitMenuBar(menu, BRect(0, 0, 100, 15), true); InitObject2(); }
BMenuField::BMenuField(const char* label, BMenu* menu, uint32 flags) : BView(NULL, flags | B_FRAME_EVENTS) { InitObject(label); _InitMenuBar(menu, BRect(0, 0, 100, 15), true); InitObject2(); }
ColourPlate::ColourPlate(ColourPlateType TheType, BOOL MonochromePlate, BOOL NegatePlate) { ERROR3IF(TheType == COLOURPLATE_SPOT, "Spot plates must be constructed with the Spot Colour constructor"); InitObject(TheType); // And override the defaults with the supplied settings Monochrome = MonochromePlate; Negate = NegatePlate; }
TRI_json_t* TRI_CreateObjectJson (TRI_memory_zone_t* zone, size_t initialSize) { TRI_json_t* result = static_cast<TRI_json_t*>(TRI_Allocate(zone, sizeof(TRI_json_t), false)); if (result != nullptr) { InitObject(zone, result, initialSize); } return result; }
obj_shape::obj_shape(string *name, double scale) { char *cname = (char*) malloc(200); strcpy (cname, name->c_str()); if((object = InitObject(cname)) == (Object*)NULL) { printf("Cannot load the object!\n"); } set_object(object); this->scale = scale; }
void CreateFiber(T* mSys, ChVector<> position) { real length = .05; real thickness = .01; ChSharedBodyPtr Fiber1 = ChSharedBodyPtr(new ChBody(new ChCollisionModelParallel)); ChSharedBodyPtr Fiber2; ChSharedBodyPtr fibers[10]; fibers[0] = ChSharedBodyPtr(new ChBody(new ChCollisionModelParallel)); Quaternion q; q.Q_from_AngZ(PI / 2.0); InitObject(fibers[0], .1, Vector(0, -2, 0) + position, q, material_fiber, true, false, -1, -2); AddCollisionGeometry(fibers[0], CYLINDER, Vector(thickness, length, length), Vector(0, 0, 0), Quaternion(1, 0, 0, 0)); AddCollisionGeometry(fibers[0], SPHERE, Vector(thickness, length, length), Vector(0, length, 0), Quaternion(1, 0, 0, 0)); AddCollisionGeometry(fibers[0], SPHERE, Vector(thickness, length, length), Vector(0, -length, 0), Quaternion(1, 0, 0, 0)); FinalizeObject(fibers[0], (ChSystemParallel *) mSys); fibers[0]->SetPos_dt(Vector(0, -1, 0)); for (int i = 1; i < 10; i++) { fibers[i] = ChSharedBodyPtr(new ChBody(new ChCollisionModelParallel)); InitObject(fibers[i], .1, Vector(i * (length + thickness) * 2, -2, 0) + position, q, material_fiber, true, false, -1, -2); AddCollisionGeometry(fibers[i], CYLINDER, Vector(thickness, length, length), Vector(0, 0, 0), Quaternion(1, 0, 0, 0)); AddCollisionGeometry(fibers[i], SPHERE, Vector(thickness, length, length), Vector(0, length, 0), Quaternion(1, 0, 0, 0)); AddCollisionGeometry(fibers[i], SPHERE, Vector(thickness, length, length), Vector(0, -length, 0), Quaternion(1, 0, 0, 0)); FinalizeObject(fibers[i], (ChSystemParallel *) mSys); fibers[i]->SetPos_dt(Vector(0, -1, 0)); ChCoordsys<> pos; pos.pos = Vector((i - 1) * (length + thickness) * 2 + length, -2, 0) + position; ChSharedPtr<ChLinkLockRevolute> joint(new ChLinkLockRevolute); joint->Initialize(fibers[i - 1], fibers[i], pos); // joint->Initialize(fibers[i - 1], fibers[i], true, Vector(length,0,0),Vector(-length,0,0),true); // joint->Set_SpringF(100); // joint->Set_SpringK(100); // joint->Set_SpringR(100); mSys->AddLink(joint); } }
static void SetUpObjects(int bpp) { int colorContext=(bpp==8) ? COLOR_CONTEXT_R8G8B8 : COLOR_CONTEXT_R5G5B5; ropObject.id=ROP_OBJECT_ID; ropObject.channel=0; ropObject.context=GENERATE_CONTEXT(UROP,0,0,0,0,0,0); InitObject(&ropObject); clipObject.id=CLIP_OBJECT_ID; clipObject.channel=0; clipObject.context=GENERATE_CONTEXT(UCLIP,0,0,0,0,0,0); InitObject(&clipObject); patternObject.id=PATTERN_OBJECT_ID; patternObject.channel=0; patternObject.context= GENERATE_CONTEXT(UPATT,0,0,0,0,colorContext,0); InitObject(&patternObject); rectObject.id=RECT_OBJECT_ID; rectObject.channel=0; rectObject.context= GENERATE_CONTEXT(URECT,PATCH_CONTEXT,0,0,1,colorContext,0); InitObject(&rectObject); blitObject.id=BLIT_OBJECT_ID; blitObject.channel=0; blitObject.context= GENERATE_CONTEXT(UBLIT,PATCH_CONTEXT,0,0,1,colorContext,0); InitObject(&blitObject); colourExpandObject.id=COLOUR_EXPAND_OBJECT_ID; colourExpandObject.channel=0; colourExpandObject.context= GENERATE_CONTEXT(UBITMAP,PATCH_CONTEXT,0,0,1,colorContext,1); InitObject(&colourExpandObject); lineObject.id=LINE_OBJECT_ID; lineObject.channel=0; lineObject.context= GENERATE_CONTEXT(ULINE,PATCH_CONTEXT,0,0,1,colorContext,0); InitObject(&lineObject); linObject.id=LIN_OBJECT_ID; linObject.channel=0; linObject.context= GENERATE_CONTEXT(ULIN,PATCH_CONTEXT,0,0,1,colorContext,0); InitObject(&linObject); }
HRESULT InitD3D(HWND hWnd) { LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION); if (pD3D == NULL) return E_FAIL; int vp = 0; D3DCAPS9 caps; if (FAILED(pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps))) { return E_FAIL; } if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) { vp = D3DCREATE_HARDWARE_VERTEXPROCESSING; } else { vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.BackBufferWidth = SCREEN_WIDTH; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.BackBufferCount = 2; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp.MultiSampleQuality = 0; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = hWnd; d3dpp.Windowed = true; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; d3dpp.Flags = 0; d3dpp.FullScreen_RefreshRateInHz = 0; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if (FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, vp, &d3dpp, &g_pDevice))) { return E_FAIL; } if (InitObject() != S_OK) { SAFE_RELEASE(pD3D); return E_FAIL; } SAFE_RELEASE(pD3D); return S_OK; }
ColourPlate::ColourPlate(IndexedColour *SpotColour, BOOL MonochromePlate, BOOL NegatePlate) { ERROR3IF(SpotColour == NULL, "Spot plates must include a valid Spot Colour!"); InitObject(COLOURPLATE_SPOT); // And override the defaults with the supplied settings Monochrome = MonochromePlate; Negate = NegatePlate; Spot.MakeRefToIndexedColour(SpotColour); }
BMenuField::BMenuField(BRect frame, const char* name, const char* label, BMenu* menu, bool fixedSize, uint32 resize, uint32 flags) : BView(frame, name, resize, flags) { InitObject(label); fFixedSizeMB = fixedSize; frame.OffsetTo(B_ORIGIN); _InitMenuBar(menu, frame, fixedSize); InitObject2(); }
ColourDragInformation::ColourDragInformation(DocColour *Colour, BOOL IsAdjust, StringBase *pColourName, BOOL IsSpot) : DragInformation(IsAdjust) { ERROR3IF(Colour == NULL, "Illegal NULL param"); InitObject(); TheColour = *Colour; LibColIsSpot = IsSpot; if (pColourName != NULL) ColourName = *pColourName; }
ColourDragInformation::ColourDragInformation(IndexedColour *Colour,BOOL IsAdjust, Document* pParent) : DragInformation(IsAdjust) { ERROR3IF(pParent == NULL, "Illegal NULL param"); InitObject(); // The IndexedColour we are dragging - if it's NULL, we're dragging "no colour" if (Colour != NULL) TheColour.MakeRefToIndexedColour(Colour); // The Parent document of the colour we are dragging pParentDoc = pParent; }
void CreateSegment(T* mSys, ChVector<> position, ChVector<> velocity) { real mass = 1; Quaternion q(1, 0, 0, 0); //q.Q_from_AngZ(PI / 2.0); string_vector[fibers] = ChSharedBodyPtr(new ChBody(new ChCollisionModelParallel)); InitObject(string_vector[fibers], mass, Vector(0, 0, 0) + position, q, material_fiber, true, false, -1, -2); AddCollisionGeometry(string_vector[fibers], SPHERE, Vector(segment_thickness, segment_length, segment_length), Vector(0, 0, 0), Quaternion(1, 0, 0, 0)); //AddCollisionGeometry(string_vector[fibers], SPHERE, Vector(segment_thickness, segment_length, segment_length), Vector(0, segment_length, 0), Quaternion(1, 0, 0, 0)); //AddCollisionGeometry(string_vector[fibers], SPHERE, Vector(segment_thickness, segment_length, segment_length), Vector(0, -segment_length, 0), Quaternion(1, 0, 0, 0)); //string_vector[fibers]->SetInertiaXX(ChVector<>(1, 1, 1)); FinalizeObject(string_vector[fibers], (ChSystemParallel *) mSys); string_vector[fibers]->SetPos_dt(velocity); fibers++; }
void ColourPlate::SetPlateInfo(ColourContext *Parent, IndexedColour *SpotColour, BOOL MonochromePlate, BOOL NegatePlate) { ERROR3IF(SpotColour == NULL, "Spot plates must include a valid Spot Colour!"); InitObject(COLOURPLATE_SPOT); Monochrome = MonochromePlate; Negate = NegatePlate; Spot.MakeRefToIndexedColour(SpotColour); if (Parent != NULL) Parent->ColourPlateHasChanged(); }
void ColourPlate::SetPlateInfo(ColourContext *Parent, ColourPlateType TheType, BOOL MonochromePlate, BOOL NegatePlate) { ERROR3IF(TheType == COLOURPLATE_SPOT, "Spot plates must be constructed with the Spot Colour constructor"); InitObject(TheType); Monochrome = MonochromePlate; Negate = NegatePlate; Spot = DocColour(COLOUR_BLACK); if (Parent != NULL) Parent->ColourPlateHasChanged(); }
void System::DoTimeStep() { if (mNumCurrentObjects < mNumObjects && mFrameNumber % 100 == 0) { float x = 1, y = numY, z = 1; float posX = 0, posY = -8, posZ = 0; srand(1); float mass = .01, mu = .5, rest = 0; ShapeType type = SPHERE; CHBODYSHAREDPTR mrigidBody; mNumCurrentObjects += x * y * z; int mobjNum = 0; for (int xx = 0; xx < x; xx++) { for (int yy = 0; yy < y; yy++) { for (int zz = 0; zz < z; zz++) { type = CYLINDER;//rand()%2;e float radius = .5;//(rand()%1000)/3000.0+.05; ChVector<> mParticlePos((xx - (x - 1) / 2.0) + posX, (yy) + posY, (zz - (z - 1) / 2.0) + posZ); //mParticlePos += ChVector<> (rand() % 1000 / 10000.0 - .05, rand() % 1000 / 10000.0 - .05, rand() % 1000 / 10000.0 - .05); ChQuaternion<> quat = ChQuaternion<> (1, 0, 0, 0);// (rand() % 1000 / 1000., rand() % 1000 / 1000., rand() % 1000 / 1000., rand() % 1000 / 1000.); ChVector<> dim; ChVector<> lpos(0, 0, 0); quat.Normalize(); mrigidBody = CHBODYSHAREDPTR(new CHBODY); InitObject(mrigidBody, mass, mParticlePos * 1.1, quat, mu, mu, rest, true, false, 0, 1); mrigidBody->SetPos_dt(ChVector<> (0, 0, 0)); switch (type) { case SPHERE: dim = ChVector<> (radius, 0, 0); case ELLIPSOID: dim = ChVector<> (radius * 1.3, radius, radius * 1.3); case BOX: dim = ChVector<> (radius, radius, radius); case CYLINDER: dim = ChVector<> (radius, radius*2, radius); } AddCollisionGeometry(mrigidBody, type, dim, lpos, quat); FinalizeObject(mrigidBody); mobjNum++; } } } } mFrameNumber++; mSystem->DoStepDynamics(mTimeStep); mCurrentTime += mTimeStep; GPUSystem->PrintStats(); }
void ColourPlate::SetType(ColourContext *Parent, ColourPlateType TheType, IndexedColour *SpotColour) { ERROR3IF(TheType == COLOURPLATE_SPOT && SpotColour == NULL, "Spot plates must include a valid Spot Colour!"); if (Type != COLOURPLATE_SPOT || Spot.FindParentIndexedColour() != SpotColour) { InitObject(TheType); if (SpotColour != NULL) Spot.MakeRefToIndexedColour(SpotColour); if (Parent != NULL) Parent->ColourPlateHasChanged(); } }
AnalogView::AnalogView(BRect r, int cpu) : _inherited(r, "", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED) { BDragger* dragger; BRect rt = r; InitObject(r, cpu); rt.OffsetTo(B_ORIGIN); rt.left = rt.right - 7; rt.top = rt.bottom - 7; rt.OffsetBy(-1, -1); dragger = new BDragger(rt, (BView *)this ); AddChild(dragger); }
BMenuField::BMenuField(BRect frame, const char* name, const char* label, BMenu* menu, uint32 resize, uint32 flags) : BView(frame, name, resize, flags) { CALLED(); TRACE("frame.width: %.2f, height: %.2f\n", frame.Width(), frame.Height()); InitObject(label); frame.OffsetTo(B_ORIGIN); _InitMenuBar(menu, frame, false); InitObject2(); }
// 開始 IZ_BOOL CStateCollada::Enter( izanagi::IMemoryAllocator* allocator, izanagi::graph::CGraphicsDevice* device, izanagi::CValue& arg) { IZ_BOOL result = InitObject( allocator, device, 30.0f, "data/ModelImage.img", "data/Seymour.msh", "data/Seymour.skl", "data/SkinShader.shd"); return result; }
/** * Creates a translucent rectangle object of the given dimensions * and returns a pointer to the object. * @param width Width of rectangle * @param height Height of rectangle */ OBJECT *TranslucentObject(int width, int height) { // template for initialising the rectangle object static const OBJ_INIT rectObj = {0, DMA_TRANS, OID_EFFECTS, 0, 0, 0}; // allocate and init a new object OBJECT *pRect = InitObject(&rectObj); // set rectangle width pRect->width = width; // set rectangle height pRect->height = height; // return pointer to rectangle object return pRect; }
//------------------------------------------------------------------------------ BMenuField::BMenuField(BMessage *data) : BView(data) { const char *label = NULL; data->FindString("_label", &label); InitObject(label); fMenuBar = (BMenuBar*)FindView("_mc_mb_"); fMenu = fMenuBar->SubmenuAt(0); InitObject2(); bool disable; if (data->FindBool("_disable", &disable) == B_OK) SetEnabled(!disable); int32 align; data->FindInt32("_align", &align); SetAlignment((alignment)align); data->FindFloat("_divide", &fDivider); bool fixed; if (data->FindBool("be:fixeds", &fixed) == B_OK) fFixedSizeMB = fixed; BMenuItem *item = fMenuBar->ItemAt(0); if (!item) return; _BMCItem_ *bmcitem = dynamic_cast<_BMCItem_*>(item); if (!bmcitem) return; bool dmark; if (data->FindBool("be:dmark", &dmark)) bmcitem->fShowPopUpMarker = dmark; }