Skip to content

First529/Deadshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deadshot

Members

  1. Napasai Sutthichutipong 6010545811
  2. Dechabhol Kotheeranurak 6010546664

Description

Deadshot is 2D shooting game for 2 players on 1 computer. Players will fight each other by using their own weapons, the last remaining player is the winner of the game. Player can select characters and maps. This game will use projectile motion formula to calculate the path of bullet under the action of gravity. The main factor of the curve path is initial velocity of bullet and angle of reach.

Main feature

  • Players can select characters and maps
  • Calculate projectile motion curve

Knowledge needed to use

  • Javafx
  • Threads
  • Swing

Purpose of this project

  • To study multi-threading
  • To study Swing

Map picture

map1

map2

	System.out.println(w + " x " + h);
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			// reference
			// https://stackoverflow.com/questions/25761438/understanding-bufferedimage-getrgb-output-values
			int pixel = image.getRGB(i, j);
			int red = (pixel >> 16) & 0xff;
			int green = (pixel >> 8) & 0xff;
			int blue = (pixel) & 0xff;
			if (red == 255 && green == 255 && blue == 255) {
				addObject(new Block(i * 32, j * 32, 0, ObjectId.Block));
			}
			if (red == 255 && green == 106 && blue == 0) {
				addObject(new Block(i * 32, j * 32, 1, ObjectId.Block1));
			}
			if (red == 64 && green == 64 && blue == 64) {
				addObject(new Block(i * 32, j * 32, 3, ObjectId.Block2));
			}
			if (red == 255 && green == 0 && blue == 0) {
				addObject(new Block(i * 32, j * 32, 2, ObjectId.BlockLava));
			}
		
		}
	
	}

Block differrentiate by pixel's color.

			x -= initV * Math.cos(Math.toRadians(angle))* timePos * 4;
			realY = ((initV * Math.sin(Math.toRadians(angle))*time) + 0.5*-9.81*time*time);
			realY2 = ((initV * Math.sin(Math.toRadians(angle))*time1) + 0.5*-9.81*time1*time1);
			diff = realY2 - realY;
			y -= diff * 10;

This code represent calculation of projectile motion using projectile motion formula and real gravity. First we calculate the position of each y then subtract it to compute delta y then multiply to estimated ratio. For x position we can ig nore it because horizontal speed is constant due to g = 0.

About

physics based multiplayer action games written in java

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published