// Keep the dart stationary relative to the dartboard (move with the dartboard), also allows dart to // scroll off the screen, hides any darts that are entirely off the screen void Dart::UpdateDart(int BGPos[]) { int actualloc[2]; bool wrapping[2] = {false, false}; actualloc[0] = loc[0] - BGPos[0]-2*8; actualloc[1] = loc[1] - BGPos[1]-2*8; if (actualloc[0] < 0) { actualloc[0] += 512; wrapping[0] = true; } if (actualloc[1] < 0) { actualloc[1] += 256; wrapping[1] = true; } Animate(); if ((wrapping[0] == true && actualloc[0]+8*8 < 512) || (wrapping[1] == true && actualloc[1]+8*8 < 256) || (wrapping[0] == false && actualloc[0] > SCREEN_WIDTH) || (wrapping[1] == false && actualloc[1] > SCREEN_HEIGHT)) { SetObject(dartnumber, ATTR0_SHAPE(0) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(0) | ATTR0_HIDE, ATTR1_SIZE(2) | ATTR1_X(0), ATTR2_ID8(64) | ATTR2_PRIO(2)); } else { SetObject(dartnumber, ATTR0_SHAPE(0) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(actualloc[1]) | ATTR0_AFF | ATTR0_AFF_DBL, ATTR1_SIZE(2) | ATTR1_X(actualloc[0]) | ATTR1_AFF(dartnumber-1), ATTR2_ID8(64) | ATTR2_PRIO(2)); } }
void GraphicsManager::Draw(EntityManager* entity_manager) { // Check for new renderable entities TODO // Get all renderable components vector<IComponent*> renderable_components = entity_manager->GetAllComponentsOfType(COMP_RENDER); int i = 0; // Iterate through the object components for (vector<IComponent*>::iterator it = renderable_components.begin(); it != renderable_components.end(); ++it) { RenderComponent* renderableComponent = (RenderComponent*)(*it); SpriteDefinition spriteDef = GetSpriteDefinition(renderableComponent->_id); int x = renderableComponent->_position.x; int y = renderableComponent->_position.y; if (x < 0) x = 511 + x; if (y < 0) y = 255 + y; SetObject(i, (spriteDef.shape << 14) | ATTR0_Y(y) | ATTR0_8BPP | ATTR0_AFF, ATTR1_SIZE(spriteDef.size) | ATTR1_X(x) | ATTR1_AFF(0), ATTR2_PALBANK(0) | ATTR2_ID4(spriteDef.char_bb_identifier)); ObjAffine* renderAffine = &( (ObjAffine*) ObjBuffer)[0]; //float theta = (float)(++player.angleDegrees % 360) * (M_PI/180); float angle = (float)(renderableComponent->_angleDegrees % 360) * (M_PI / 180); renderAffine->pa = float2fx( cos(angle) ); renderAffine->pb = float2fx( -sin(angle) ); renderAffine->pc = float2fx( sin(angle) ); renderAffine->pd = float2fx( cos(angle) ); ++i; } UpdateObjects(); // Get all background components vector<IComponent*> background_components = entity_manager->GetAllComponentsOfType(COMP_BACKGROUND); // Iterate through the background components for (vector<IComponent*>::iterator it = background_components.begin(); it != background_components.end(); ++it) { BackgroundComponent* backgroundComponent = (BackgroundComponent*)(*it); // Scroll background if (backgroundComponent->_background_id == BG_PIPES) { REG_BG1HOFS = backgroundComponent->_integer_position.x; } // Update tiles if (backgroundComponent->_background_id == BG_PIPES || backgroundComponent->_background_id == BG_SCORE) { for (int x = 0; x < 32; x++) { for (int y = 0; y < 32; y++) { DisplayTile(x, y, backgroundComponent->_tiles[x][y], backgroundComponent->_screen_bb); } } } if (backgroundComponent->_update_screen) { for (int x = 0; x < 32; x++) { for (int y = 0; y < 32; y++) { DisplayTile(x, y, backgroundComponent->_tiles[x][y], backgroundComponent->_screen_bb); } } backgroundComponent->_update_screen = false; } } }