player controller
parent
6e159d301f
commit
56c5695267
|
|
@ -1 +1,2 @@
|
|||
/spacewars/
|
||||
/Space Wars/
|
||||
|
|
|
|||
|
|
@ -1,3 +1,14 @@
|
|||
[diveengine2d.Entity]
|
||||
$GUID = "9e477f6d-778d-43e2-afe0-028a0a99cd74"
|
||||
$name = "background"
|
||||
|
||||
Component RectRenderer
|
||||
$name = "render!"
|
||||
$width = 1024i
|
||||
$height = 600i
|
||||
$color = #f0f0f0
|
||||
End Component
|
||||
|
||||
[diveengine2d.Entity]
|
||||
$GUID = "9e477f6d-778d-43e2-afe0-028a0a99cd74"
|
||||
$name = "Player"
|
||||
|
|
@ -5,11 +16,39 @@ $name = "Player"
|
|||
Component spacewars.PlayerController
|
||||
$name = "player controller"
|
||||
$message = "hello from the script!"
|
||||
$speed = 2i
|
||||
End Component
|
||||
|
||||
Component RectRenderer
|
||||
$name = "render!"
|
||||
$width = 16F
|
||||
$height = 16F
|
||||
$color = #776611
|
||||
End Component
|
||||
$width = 16i
|
||||
$height = 16i
|
||||
$color = #05FABB
|
||||
End Component
|
||||
|
||||
Component RigidBody
|
||||
$name = "poop"
|
||||
$friction = .9F
|
||||
End Component
|
||||
|
||||
[diveengine2d.Entity]
|
||||
$GUID = "9e477f6d-778d-43e2-afe0-028a0a99cd74"
|
||||
$name = "Player"
|
||||
|
||||
Component spacewars.PlayerController
|
||||
$name = "player controller"
|
||||
$message = "hello from the script!"
|
||||
$speed = 1f
|
||||
End Component
|
||||
|
||||
Component RectRenderer
|
||||
$name = "render!"
|
||||
$width = 16i
|
||||
$height = 16i
|
||||
$color = #FA05BB
|
||||
End Component
|
||||
|
||||
Component RigidBody
|
||||
$name = "poop"
|
||||
$friction = .9F
|
||||
End Component
|
||||
|
|
|
|||
|
|
@ -1,3 +1,14 @@
|
|||
[diveengine2d.Entity]
|
||||
$GUID = "9e477f6d-778d-43e2-afe0-028a0a99cd74"
|
||||
$name = "background"
|
||||
|
||||
Component RectRenderer
|
||||
$name = "render!"
|
||||
$width = 1024i
|
||||
$height = 600i
|
||||
$color = #f0f0f0
|
||||
End Component
|
||||
|
||||
[diveengine2d.Entity]
|
||||
$GUID = "9e477f6d-778d-43e2-afe0-028a0a99cd74"
|
||||
$name = "Player"
|
||||
|
|
@ -5,11 +16,39 @@ $name = "Player"
|
|||
Component spacewars.PlayerController
|
||||
$name = "player controller"
|
||||
$message = "hello from the script!"
|
||||
$speed = 2i
|
||||
End Component
|
||||
|
||||
Component RectRenderer
|
||||
$name = "render!"
|
||||
$width = 16F
|
||||
$height = 16F
|
||||
$color = #776611
|
||||
End Component
|
||||
$width = 16i
|
||||
$height = 16i
|
||||
$color = #05FABB
|
||||
End Component
|
||||
|
||||
Component RigidBody
|
||||
$name = "poop"
|
||||
$friction = .9F
|
||||
End Component
|
||||
|
||||
[diveengine2d.Entity]
|
||||
$GUID = "9e477f6d-778d-43e2-afe0-028a0a99cd74"
|
||||
$name = "Player"
|
||||
|
||||
Component spacewars.PlayerController
|
||||
$name = "player controller"
|
||||
$message = "hello from the script!"
|
||||
$speed = 1f
|
||||
End Component
|
||||
|
||||
Component RectRenderer
|
||||
$name = "render!"
|
||||
$width = 16i
|
||||
$height = 16i
|
||||
$color = #FA05BB
|
||||
End Component
|
||||
|
||||
Component RigidBody
|
||||
$name = "poop"
|
||||
$friction = .9F
|
||||
End Component
|
||||
|
|
|
|||
|
|
@ -1,7 +1,29 @@
|
|||
package spacewars;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import diveengine2d.DiveScript;
|
||||
import diveengine2d.Input;
|
||||
import diveengine2d.RigidBody;
|
||||
|
||||
public class PlayerController extends DiveScript {
|
||||
public String message = null;
|
||||
public float speed;
|
||||
|
||||
private RigidBody rigidBody;
|
||||
|
||||
public void create() {
|
||||
rigidBody = (RigidBody) entity.components.get(2);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if(Input.getKeyDown(KeyEvent.VK_W))
|
||||
rigidBody.dy += -1 * speed;
|
||||
if(Input.getKeyDown(KeyEvent.VK_S))
|
||||
rigidBody.dy += 1 * speed;
|
||||
if(Input.getKeyDown(KeyEvent.VK_A))
|
||||
rigidBody.dx += -1 * speed;
|
||||
if(Input.getKeyDown(KeyEvent.VK_D))
|
||||
rigidBody.dx += 1 * speed;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue