صدى البلد البلد سبورت قناة صدى البلد صدى البلد جامعات صدى البلد عقارات
Supervisor Elham AbolFateh
Editor in Chief Mohamed Wadie
ads

128x160 Snake Xenzia Java Game Access

private void spawnFood() // simple random do foodX = (int)(Math.random() * W); foodY = (int)(Math.random() * H); while(collidesWithSnake(foodX, foodY));

// game data private static final int W = 15, H = 18; private int[] snakeX = new int[400]; private int[] snakeY = new int[400]; private int length, direction, nextDir; private int foodX, foodY; private int score; 128x160 snake xenzia java game

g.setColor(0xFFFFFF); // head highlight g.fillRect(offsetX + x[0]*CELL_SIZE + 2, offsetY + y[0]*CELL_SIZE + 2, 4,4); g.setColor(0xFF0000); g.fillArc(offsetX + foodX*CELL_SIZE, offsetY + foodY*CELL_SIZE, CELL_SIZE, CELL_SIZE, 0, 360); Score Display Draw at top: Score: 0 using small font ( Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL ). 6. Input Handling Override keyPressed(int keyCode) in Canvas: private void spawnFood() // simple random do foodX