###################### ### Jessist Script ### ###################### # This script is part of Jessist # Jessist is licensed under GNU GPLv3 # # This script manages the player object extends AnimatedSprite class_name Player # Animation and code stuff var developmentVersion = true var verboseMessages = true var playerAction = null var playerFacing = null # Player information export var playerJump = 600#*1.5 export var playerJumpActive = false export var playerJumpCurrent = 0 export var playerSpeed = 175 #export var playerSpeed = 500 export var gravitySpeed = 600 export var currentLevel = 0 export var position_y = 0 export var position_x = 0 export var collectables = 0 export var powerup_speed = false export var gravityVector = 0 export var moveVector = Vector2(0,0) export var noGravity = 0 # Cheats var cheats_fly = false func _ready(): if not developmentVersion: verboseMessages = false print("=> Initializing player object") playerAction = "STANDING" playerFacing = "RIGHT" func _process(delta): animManager() cheatManager() moveVector.x = 0 if cheats_fly: gravityVector = 0 noGravity = 0 else: if not noGravity == 0: print("==> noGravity is at " + String(noGravity)) noGravity -= 1 gravityVector = 0 else: gravityVector += gravitySpeed * delta if gravityVector > 1600: gravityVector = 1600 if verboseMessages: print("==> gravityVector above 1600, throttling") if playerJumpActive: if playerJumpCurrent >= playerJump: noGravity = 0 playerJumpActive = false playerJumpCurrent = 0 else: if playerJumpCurrent >= 500: playerJumpCurrent += (playerJump / 2) * delta -2500 else: playerJumpCurrent += (playerJump / 2) * delta gravityVector -= playerJumpCurrent noGravity = 1 moveVector.y = +gravityVector inputHandler() if verboseMessages: print("==> Current velocity: x" + String(moveVector.x) + " y" + String(moveVector.y)) get_parent().move_and_slide(moveVector,Vector2(0,-1)) func animManager(): if playerFacing == "LEFT": animation = "WalkingLeft" elif playerFacing == "RIGHT": animation = "WalkingRight" if playerAction == "WALKING" or playerAction == "JUMPING": playing = true else: frame = 0 playing = false func cheatManager(): if Input.is_action_just_pressed("cheats_fly"): if cheats_fly: cheats_fly = false print("=> CHEATS: cheats_fly is off") else: cheats_fly = true print("=> CHEATS: cheats_fly is on") func inputHandler(): if Input.is_action_pressed("ui_left"): if verboseMessages: print("==> Left pressed") playerFacing = "LEFT" playerAction = "WALKING" moveVector.x = moveVector.x-playerSpeed elif Input.is_action_pressed("ui_right"): if verboseMessages: print("==> Right pressed") playerFacing = "RIGHT" playerAction = "WALKING" moveVector.x = moveVector.x+playerSpeed elif Input.is_action_just_pressed("ui_up"): if verboseMessages: print("==> Up pressed") if get_parent().is_on_floor(): playerAction = "JUMPING" playerJumpActive = true noGravity = 60 else: playerAction = "STANDING"