mirror of
https://github.com/csd4ni3l/aim-trainer.git
synced 2026-01-01 04:03:42 +01:00
Add 100% accuracy test and add controller support for the game only(not ui)
This commit is contained in:
@@ -4,7 +4,7 @@ min_enemy_movement = 7
|
||||
max_enemy_movement = 10
|
||||
enemy_health = 100
|
||||
|
||||
game_modes = ["Training", "Waves", "1 Minute Test"]
|
||||
game_modes = ["Training", "Waves", "1 Minute Test", "100% Accuracy Test"]
|
||||
|
||||
weapons = {
|
||||
"assault_rifle": {"dmg": 20, "atk_speed": 0.2, "image": "assets/graphics/assaultrifle.png"},
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from panda3d.core import GraphicsPipeSelection
|
||||
from ursina.prefabs.dropdown_menu import DropdownMenu
|
||||
from ursina.prefabs.file_browser import FileBrowser
|
||||
from ursina.prefabs.first_person_controller import FirstPersonController
|
||||
from ursina import *
|
||||
|
||||
def get_closest_resolution():
|
||||
allowed_resolutions = [(1366, 768), (1440, 900), (1600,900), (1920,1080), (2560,1440), (3840,2160)]
|
||||
@@ -76,4 +78,57 @@ def is_float(string):
|
||||
float(string)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
return False
|
||||
|
||||
class FixedFirstPersonController(FirstPersonController):
|
||||
def update(self):
|
||||
self.rotation_y += mouse.velocity[0] * self.mouse_sensitivity[1]
|
||||
|
||||
look_x = mouse.velocity[0] + held_keys.get('gamepad right stick x', 0) * 0.01
|
||||
look_y = mouse.velocity[1] + held_keys.get('gamepad right stick y', 0) * 0.01
|
||||
|
||||
self.rotation_y += look_x * self.mouse_sensitivity[1]
|
||||
self.camera_pivot.rotation_x -= look_y * self.mouse_sensitivity[0]
|
||||
self.camera_pivot.rotation_x = clamp(self.camera_pivot.rotation_x, -90, 90)
|
||||
|
||||
self.direction = Vec3(
|
||||
self.forward * ((held_keys['w'] - held_keys['s']) + held_keys["gamepad left stick y"])
|
||||
+ self.right * ((held_keys['d'] - held_keys['a']) + held_keys["gamepad left stick x"])
|
||||
).normalized()
|
||||
|
||||
feet_ray = raycast(self.position+Vec3(0,0.5,0), self.direction, traverse_target=self.traverse_target, ignore=self.ignore_list, distance=.5, debug=False)
|
||||
head_ray = raycast(self.position+Vec3(0,self.height-.1,0), self.direction, traverse_target=self.traverse_target, ignore=self.ignore_list, distance=.5, debug=False)
|
||||
if not feet_ray.hit and not head_ray.hit:
|
||||
move_amount = self.direction * time.dt * self.speed
|
||||
|
||||
if raycast(self.position+Vec3(-.0,1,0), Vec3(1,0,0), distance=.5, traverse_target=self.traverse_target, ignore=self.ignore_list).hit:
|
||||
move_amount[0] = min(move_amount[0], 0)
|
||||
if raycast(self.position+Vec3(-.0,1,0), Vec3(-1,0,0), distance=.5, traverse_target=self.traverse_target, ignore=self.ignore_list).hit:
|
||||
move_amount[0] = max(move_amount[0], 0)
|
||||
if raycast(self.position+Vec3(-.0,1,0), Vec3(0,0,1), distance=.5, traverse_target=self.traverse_target, ignore=self.ignore_list).hit:
|
||||
move_amount[2] = min(move_amount[2], 0)
|
||||
if raycast(self.position+Vec3(-.0,1,0), Vec3(0,0,-1), distance=.5, traverse_target=self.traverse_target, ignore=self.ignore_list).hit:
|
||||
move_amount[2] = max(move_amount[2], 0)
|
||||
self.position += move_amount
|
||||
|
||||
# self.position += self.direction * self.speed * time.dt
|
||||
|
||||
|
||||
if self.gravity:
|
||||
# gravity
|
||||
ray = raycast(self.world_position+(0,self.height,0), self.down, traverse_target=self.traverse_target, ignore=self.ignore_list)
|
||||
|
||||
if ray.distance <= self.height+.1:
|
||||
if not self.grounded:
|
||||
self.land()
|
||||
self.grounded = True
|
||||
# make sure it's not a wall and that the point is not too far up
|
||||
if ray.world_normal.y > .7 and ray.world_point.y - self.world_y < .5: # walk up slope
|
||||
self.y = ray.world_point[1]
|
||||
return
|
||||
else:
|
||||
self.grounded = False
|
||||
|
||||
# if not on ground and not on way up in jump, fall
|
||||
self.y -= min(self.air_time, ray.distance-.05) * time.dt * 100
|
||||
self.air_time += time.dt * .25 * self.gravity
|
||||
Reference in New Issue
Block a user