本文整理汇总了C++中Enemy::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::Draw方法的具体用法?C++ Enemy::Draw怎么用?C++ Enemy::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::Draw方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateGameplay
void UpdateGameplay(float a_deltaTime)
{
SetBackgroundColour(SColour(00, 67, 171, 50));
DrawSprite(player.spriteID);
enemy.Draw();
enemy2.Draw();
MoveSprite(player.spriteID,player.x, player.y);
player.Movement(a_deltaTime, 750, 500);
enemy.Movement(a_deltaTime, 500, 500);
enemy2.Movement(a_deltaTime, 500, 500);
}
示例2: Draw
void EnemyManager::Draw()
{
for (int i = 0; i < m_enemies->size(); i++)
{
Enemy* e = m_enemies->at(i);
e->Draw();
}
}
示例3: main
int main()
{
// Init GLFW
glfwInit();
// Create a GLFWwindow object that we can use for GLFW's functions
Window window = Window(WIDTH, HEIGHT, TITLE);
window.DefineViewport();
//glfwSetInputMode(window.getWindowPtr(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
/// ^(Maybe use this later)
// Callback functions
glfwSetKeyCallback(window.getWindowPtr() , key_callback);
// Init GLEW
glewExperimental = GL_TRUE;
glewInit();
// Enable alpha channel transparency
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Load and compile shaders to a program
Shader ShaderProgram = Shader("../deps/shaders/shadervert.vs", "../deps/shaders/shaderfrag.fs");
// Load explosion graphics
extern_Explosion.Init(ShaderProgram.GetProgramID());
// Load texture/Game objects
Texture2D texture_background1 = Texture2D("../deps/textures/backgroundSpace_01.1.png", PNG_RGB);
SpriteMap Background = SpriteMap(texture_background1, 1.0f, 1.0f, glm::vec3(0.0f, 0.0f, 0.0f), 1.0f, BACKGROUND);
Player PlayerShip;
PlayerShip.Init(moveSpeed);
Enemy Enemies;
Enemies.Init();
// Projection matrix: ortho for 2D
glm::mat4 proj = glm::ortho(0, window.getWidth(), 0, window.getHeight());
// Game loop
while (!window.ShouldClose())
{
double startFrame = glfwGetTime(); ///< for FPS limiting
// Check if any events have been activiated and call callback function (via GLFW)
glfwPollEvents();
// Clear the colorbuffer
glClearColor(0.6f, 0.8f, 0.8f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* Drawing */
ShaderProgram.Use();
// Background position and drawing calculations - just identity matrix
glm::mat4 model;
GLint modelLoc = glGetUniformLocation(ShaderProgram.GetProgramID(), "model");
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));
Background.BackgroundScroll(scrollSpeed);
Background.Draw();
Collision::EnemyHit(&PlayerShip, &Enemies);
Collision::PlayerHit(&PlayerShip, &Enemies);
Collision::ShipsCollide(&PlayerShip, &Enemies);
PlayerShip.Move(keys);
PlayerShip.AddShots(keys);
PlayerShip.Draw(ShaderProgram.GetProgramID());
Enemies.Move();
Enemies.Shoot(PlayerShip.GetPosition());
Enemies.Draw(ShaderProgram.GetProgramID());
extern_Explosion.Draw();
// FPS Calculation/Limiting
float fps = CalculateFPS();
static int printFPS = 0;
if (printFPS == 100) {
Enemies.Add(EN_0, PlayerShip.GetPosition());
Enemies.Add(EN_1, PlayerShip.GetPosition());
std::cout << fps << std::endl;
printFPS = 0;
} else {
printFPS++;
}
LimitFPS(FPS, startFrame);
if (PlayerShip.GetLives() <= 0)
{
window.Close();
}
//.........这里部分代码省略.........
示例4: wmain
//.........这里部分代码省略.........
// Run the thread
//Player * p = (); // pointer to object
void * pv = &player; // pointer to void
Player * p2 = static_cast<Player *>(pv); // pointer to the same object
int data;
SDL_Thread* threadID = SDL_CreateThread(renderThreadFunction, "RenderThread", (void*)p2);
// THREADS \\
#pragma endregion
#pragma region SDL STUFF
bool quit = false;
float oldTime = SDL_GetTicks();
float delta = 0.f;
float newTime = 0.f;
SDL_Event e;
fpsTimer.start();
while (!quit)
{
while (SDL_PollEvent(&e) != 0)
{
InputManager::GetInstance()->UpdatePolledEvents(e);
}
if (e.button.button == SDL_SCANCODE_ESCAPE)
quit = true;
// THREADS \\
// THREADS \\
//controls gameState added in game menu feature
r.Begin();
switch (gameState)
{
case MENU:
//detect button click
if (e.type == SDL_MOUSEBUTTONDOWN)
{
//If the left mouse button was pressed
if (e.button.button == SDL_BUTTON_LEFT)
{
//Get the mouse offsets
int mouse_x = e.button.x;
int mouse_y = e.button.y;
if (playBtn.IsClicked(mouse_x, mouse_y))
{
gameState = PLAY;
}
else if (exitBtn.IsClicked(mouse_x, mouse_y))
{
quit = true;
}
}
}// End detect button click
background.Draw(r);
playBtn.Draw(r);
exitBtn.Draw(r);
break;
case PLAY:
newTime = SDL_GetTicks();
delta = newTime - oldTime;
oldTime = newTime;
en.Update(delta);
lvl.Draw(r);
en.Draw(r);
en1.Update(delta);
en1.Draw(r);
en.Draw(r);
player.Update(r, delta);
player.Draw(r);
//calculateFPS();
break;
}
InputManager::GetInstance()->UpdateState();
r.End();
}
//Remove timer in case the call back was not called
SDL_WaitThread(threadID, NULL);
return EXIT_SUCCESS;
}
示例5: draw
void BasicApp::draw()
{
// this pair of lines is the standard way to clear the screen in OpenGL
gl::clear( Color( 0.0f, 0.0f, 0.0f ) );
gl::setMatricesWindow( getWindowSize() );
if(game_state == Game_Demo)
{
gl::enableAlphaBlending( true );
for (list<Asteroid>::iterator itr = asteroids.begin(); itr!=asteroids.end(); itr++)
{
if(itr->m_bHit)
{
}
itr->Draw();
}
Font font = Font( "Times New Roman", 50 );
gl::drawString("Atari Asteroids Clone" , Vec2f(app::getWindowWidth()/4,app::getWindowHeight()/4),cinder::ColorA(1,1,1,1), font);
gl::drawString("Presse SpaceBar to Play" , Vec2f(app::getWindowWidth()/4,app::getWindowHeight()/2 + 100),cinder::ColorA(1,1,1,1), font);
}
else if(game_state == GAME_Play)
{
for (list<Asteroid>::iterator itr = asteroids.begin(); itr!=asteroids.end(); itr++)
{
if(itr->m_bHit)
{
}
itr->Draw();
}
enemy.Draw();
particleManager.Move();
particleManager.Draw();
particleLineManager.Update();
particleLineManager.Draw();
currentShip.Draw();
for (std::vector<Ship>::iterator itrShip = ships.begin(); itrShip!=ships.end();itrShip++)
{
if(itrShip->m_state== Ship::Ship_Alive)
{
itrShip->Draw();
}
}
stringstream scoreString;
scoreString<< score;
gl::drawString(" " + scoreString.str(), Vec2f(10,10),cinder::ColorA(1,1,1,1), mFont);
}
else if (game_state == GAME_End)
{
gl::drawString("Game Over", Vec2f(getWindowWidth()/2,getWindowHeight()/2),cinder::ColorA(1,1,1,1), mFont);
}
}