Skip to content
Snippets Groups Projects
Commit 3630b3d1 authored by ZERBIB TIMOTHEE's avatar ZERBIB TIMOTHEE
Browse files

Merging manually added files

parents 18aff0bc db5ce46e
Branches
Tags
No related merge requests found
......@@ -5,6 +5,10 @@
[node name="lobby" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -1.0
margin_top = 1.0
margin_right = -1.0
margin_bottom = 1.0
script = ExtResource( 1 )
[node name="menu" type="Panel" parent="."]
......
extends Node
var movementInput:int = 0
var jumpInput:bool = false
var jumpId:int = 0
var sprintInput:bool = false
func _physics_process(delta):
......@@ -15,10 +16,8 @@ func getPlayerInput():
if Input.is_action_pressed("movementRight"):
movementInput += 1
if Input.is_action_pressed("movementJump"):
jumpInput = true
else:
jumpInput = false
if Input.is_action_just_pressed("movementJump"):
jumpId += 1
if Input.is_action_pressed("movementSprint"):
sprintInput = true
......@@ -26,4 +25,4 @@ func getPlayerInput():
sprintInput = false
# Sent without safety resend
rpc_unreliable_id(1, "sendPlayerInputs", movementInput, sprintInput, jumpInput)
\ No newline at end of file
rpc_unreliable_id(1, "sendPlayerInputs", movementInput, sprintInput, jumpId)
\ No newline at end of file
......@@ -18,27 +18,50 @@ var isJumping:bool = false
const GRAVITY:float = -28.0
# Velocity updated continuously by move_and_slide
var vel:Vector3 = Vector3()
var vel:Vector3 = Vector3(0,0,0)
# move_and_slide need that
const FLOOR_NORMAL:Vector3 = Vector3(0,1,0)
# Character informations
var damages:int = 0
var maxJump:int = 2 # Maximum number of jump that a character can do
var currentJump:int = 0 # Actual number of jump
var lastJumpId:int = 0 # Detect a new jump
var lastPunchId:int = 0 # Detect a new punch (of any type)
var idleTime:float = 0 # Stun when hitted + prevent spam
# called by the engine
func _physics_process(delta):
processMovement(delta)
broadcastMovement(delta)
# Called from the game script to update the vars
func getPlayerInputs(movementInput, sprintInput, jumpInput):
func getPlayerInputs(movementInput, sprintInput, jumpId):
if lastJumpId != jumpId:
lastJumpId = jumpId
isJumping = true
else:
isJumping = false
motion = movementInput
isSprinting = sprintInput
isJumping = jumpInput
func processMovement(delta):
# reset max_jump
if self.is_on_floor():
if isJumping:
vel.y = JUMP_SPEED
currentJump = 0
if isJumping:
if currentJump < maxJump:
currentJump += 1
vel.y = JUMP_SPEED - delta*GRAVITY
# Consider the gravity
vel.y += delta * GRAVITY
......
[gd_scene load_steps=3 format=2]
[ext_resource path="res://entities/characters/player.gd" type="Script" id=1]
[ext_resource path="res://entities/characters/Class1/class1.gd" type="Script" id=1]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 0.175, 0.275, 0.7 )
......
extends Node
master func sendPlayerInputs(movementInput, jumpInput, sprintInput):
master func sendPlayerInputs(movementInput, sprintInput, jumpId):
# Get the input from a client and send it to the matchig remote player
var senderId = get_tree().get_rpc_sender_id()
gamestate.get_node("/root/game/"+str(senderId)).getPlayerInputs(movementInput, jumpInput, sprintInput)
\ No newline at end of file
gamestate.get_node("/root/game/"+str(senderId)).getPlayerInputs(movementInput, sprintInput, jumpId)
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment