/** * 描画処理 * * @param 描画オブジェクト */ public void paintComponent(Graphics g) { super.paintComponent(g); // 背景を黒で塗りつぶす g.setColor(Color.BLACK); g.fillRect(0, 0, getWidth(), getHeight()); // X方向のオフセットを計算 int offsetX = MainPanel.WIDTH / 2 - (int) player.getX(); // マップの端ではスクロールしないようにする offsetX = Math.min(offsetX, 0); offsetX = Math.max(offsetX, MainPanel.WIDTH - map.getWidth()); // Y方向のオフセットを計算 int offsetY = MainPanel.HEIGHT / 2 - (int) player.getY(); // マップの端ではスクロールしないようにする offsetY = Math.min(offsetY, 0); offsetY = Math.max(offsetY, MainPanel.HEIGHT - map.getHeight()); // マップを描画 map.draw(g, offsetX, offsetY); // プレイヤーを描画 player.draw(g, offsetX, offsetY); // スプライトを描画 // マップにいるスプライトを取得 LinkedList sprites = map.getSprites(); Iterator iterator = sprites.iterator(); while (iterator.hasNext()) { Sprite sprite = (Sprite) iterator.next(); sprite.draw(g, offsetX, offsetY); } }
public void renderGL() { GL11.glClear( GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer GL11.glColor3f(0.5f, 0.5f, 1.0f); // set the color of the quad (R,G,B,A) GL11.glBegin(GL11.GL_QUADS); // draw quad GL11.glVertex2f(100, 100); GL11.glVertex2f(100 + 200, 100); GL11.glVertex2f(100 + 200, 100 + 200); GL11.glVertex2f(100, 100 + 200); GL11.glEnd(); font.draw_str("HELLO", 150, 150); s.draw(100, 400, 2f); s.draw(300, 400, 2.23f); GL11.glColor3f(0.5f, 0.5f, 1.0f); // R,G,B,A Set The Color To Blue One Time Only GL11.glPushMatrix(); // draw quad GL11.glTranslatef(x, y, 0); GL11.glRotatef(rotation, 0f, 0f, 1f); GL11.glTranslatef(-x, -y, 0); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(x - 50, y - 50); GL11.glVertex2f(x + 50, y - 50); GL11.glVertex2f(x + 50, y + 50); GL11.glVertex2f(x - 50, y + 50); GL11.glEnd(); GL11.glPopMatrix(); }
// draw public void draw(GL10 gl) { if (lastTime == 0) return; switch (game_state) { case SPLASH_SCREEN: // gray gl.glClearColor(0.4f, 0.4f, 0.4f, 1.0f); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); sprite.draw(gl, xPos, yPos, win_width, win_height, winScale); break; case MAIN_MENU: // red gl.glClearColor(1f, 0.4f, 0.4f, 1.0f); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); sprite.draw(gl, xPos, yPos, win_width, win_height, winScale); break; case PLAYING: // green if (touching) gl.glClearColor(0.4f, 1f, 1f, 1.0f); else gl.glClearColor(0.4f, 1f, 0.4f, 1.0f); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); sprite.draw(gl, xPos, yPos, win_width, win_height, winScale); break; } }
/** * Render the game (part of the main loop, no allocations anywhere in here). * * @param gl openGL context reference */ public void render(GL10 gl) { GLGfx.clearScreen(gl, true, CLEAR_COLOR, true); mBack.draw(gl); GLGfx.drawLine( gl, RAIL_COLOR, 0, BANNER_HEIGHT * mDensity, getWidth(), BANNER_HEIGHT * mDensity); mPaddles[0].draw(gl); mPaddles[1].draw(gl); mBall.draw(gl); }
@Override public void render(GameContainer gc, StateBasedGame sb, Graphics g) throws SlickException { Input input = gc.getInput(); gc.setShowFPS(false); background.draw(0, 0); if (shoes.spriteCollisionByPoint(input.getAbsoluteMouseX(), input.getAbsoluteMouseY())) g.drawImage(shoes.image, shoes.x, shoes.y, Color.blue); else shoes.draw(g); if (bib.spriteCollisionByPoint(input.getAbsoluteMouseX(), input.getAbsoluteMouseY())) g.drawImage(bib.image, bib.x, bib.y, Color.red); else bib.draw(g); g.setColor(Color.black); g.drawString("PR - " + PR / 60 + ":" + String.format("%02d", PR % 60), 230, 75); g.setColor(Color.white); } // end render
@Override public void onDrawFrame(GL10 gl) { // Set GL_MODELVIEW transformation mode // gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); // reset the matrix to its default state // When using GL_MODELVIEW, you must set the camera view // GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f); GLES20.glClearColor(0.8f, 0.0f, 0.0f, 1.0f); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); triangle.draw(); sprite.draw(gl); }
public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); rotation = (rotation + 0); sprite.setSize(screenRectangle.width, screenRectangle.height); sprite.setPosition(screenRectangle.x, screenRectangle.y); sprite.setOriginCenter(); if (Gdx.input.isKeyJustPressed(keyRight)) { body.setTransform(body.getPosition().x + 5, body.getPosition().y, body.getAngle()); } elapsedTime += Gdx.graphics.getDeltaTime(); // body.setTransform(body.getPosition(), rotation); batch.end(); batch.begin(); sprite.setRotation(rotation); sprite.draw(batch); // batch.draw(animation.getKeyFrame(elapsedTime, true), screenRectangle.x, screenRectangle.y, // screenRectangle.width, screenRectangle.height ); // animation.setFrameDuration(0.09f); }
@Override public void draw(Graphics gfx, Point p) { _sprite.draw(gfx, p); }
@Override public void draw() { sprite.draw(spriteBatch); }
public void draw(Graphics g) { sprite.draw(g, (int) x, (int) y); }
public void render() { if (mouseIsHovering && buttonIsPressedDown) pressedTexture.draw(rect); else mainTexture.draw(rect); }
public void draw() { canvas.pushMatrix(); canvas.translate(this.position.x, this.position.y); sprite.draw(this.size); canvas.popMatrix(); }
public void draw(double deltaTime) { update(deltaTime); super.draw(deltaTime); }