Task 1, Seek
test.SeekScenario를 찾아서 실행해보라.
2대의 자동차가 나온다.
1대는 키보드로 제어할 수 있지만, 다른 1대는 아무것도 하지 않는다.
일단, 새로운 컨트롤러를 만들어라. (controllers.SeekController)
그리고 여기서 GameObject와 target을 받아라.
그리고 그 Seek이 target을 계속 쫓게 만들어라.
"Seek" steering behavior을 사용해라
이 controller를 car2 (blue)에 적용해라 .
package test;
import controllers.EmptyController;
import controllers.KeyboardController;
import engine.Car;
import engine.Game;
import engine.GameObject;
import engine.GameWindow;
import engine.Obstacle;
import java.awt.Color;
/**
*
* @author santi
*/
public class SeekScenario {
/*
Goal of this exercise:
- Write a controller for "car2" that uses the "Seek" steerig behavior to always run
after car1 (that is controlled using the arrow keys).
*/
public static void main(String args[]) throws Exception {
Game game = new Game(800,600, 25);
// set up the outside walls:
game.add(new Obstacle(0,0,800,25,Color.GRAY));
game.add(new Obstacle(0,575,800,25,Color.GRAY));
game.add(new Obstacle(0,0,25,600,Color.GRAY));
game.add(new Obstacle(775,0,25,600,Color.GRAY));
// set up the cars and markers:
GameObject car1 = new Car("graphics/redcar.png",200,300,-Math.PI/2, new KeyboardController());
GameObject car2 = new Car("graphics/bluecar.png",600,300,-Math.PI/2, new EmptyController());
game.add(car1);
game.add(car2);
GameWindow.newWindow(game);
}
}
* 참고 문서 (숙제링크)
https://www.cs.drexel.edu/~so367/teaching/2017/CS387/projects.html
'Game AI & Unity > Java Steering game' 카테고리의 다른 글
[Game AI][Steering Behavior] 18. Task_Seek (controllers.SeekController) (0) | 2024.03.20 |
---|---|
[Game AI][Steering Behavior] 17. Task_Seek (test.SeekScenario ) (0) | 2024.03.20 |
[Game AI][Steering Behavior] 15 KeyboardExample.java (0) | 2024.03.20 |
[Game AI][Steering Behavior] 14 engine.RotatedRectangle (0) | 2024.03.20 |
[Game AI][Steering Behavior] 13. engine.Obstacle (0) | 2024.03.20 |