Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported the WHOLE game to vitrix engine #53

Merged
merged 9 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ panda3d==1.10.11
panda3d-gltf==0.13
panda3d-simplepbr==0.10
Pillow==9.1.0
ursina==4.1.1
git+https://github.com/ShadityZ/Vitrix-Engine.git#egg=vitrix_engine # for vitrix_engine
venvctl==1.4.12
4 changes: 2 additions & 2 deletions vitrix/lib/UI/inventory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
from vitrix_engine import *
from vitrix_engine.prefabs.first_person_controller import FirstPersonController



Expand Down
22 changes: 11 additions & 11 deletions vitrix/lib/entities/bullet.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import ursina
from vitrix_engine import *
import os

from lib.entities.enemy import Enemy, Zombie
from lib.paths import GamePaths


class Bullet(ursina.Entity):
class Bullet(Entity):

def __init__(self, position: ursina.Vec3, direction: float, x_direction: float, network=False, damage: int = 10, slave=False):
def __init__(self, position: Vec3, direction: float, x_direction: float, network=False, damage: int = 10, slave=False):
if network == False:
self.singleplayer = True

speed = 50
dir_rad = ursina.math.radians(direction)
x_dir_rad = ursina.math.radians(x_direction)
dir_rad = math.radians(direction)
x_dir_rad = math.radians(x_direction)


self.velocity = ursina.Vec3(
ursina.math.sin(dir_rad) * ursina.math.cos(x_dir_rad),
ursina.math.sin(x_dir_rad),
ursina.math.cos(dir_rad) * ursina.math.cos(x_dir_rad)
self.velocity = Vec3(
math.sin(dir_rad) * math.cos(x_dir_rad),
math.sin(x_dir_rad),
math.cos(dir_rad) * math.cos(x_dir_rad)
) * speed

#bullet_tags ={
Expand Down Expand Up @@ -58,7 +58,7 @@ def __init__(self, position: ursina.Vec3, direction: float, x_direction: float,


def update(self):
self.position += self.velocity * ursina.time.dt
self.position += self.velocity * time.dt
# self.rotation_z+=6
hit_info = self.intersects()

Expand All @@ -70,4 +70,4 @@ def update(self):
if self.singleplayer == False:
self.network.send_health(entity)

ursina.destroy(self)
destroy(self)
6 changes: 3 additions & 3 deletions vitrix/lib/entities/crate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import ursina
from vitrix_engine import *
import random

from lib.paths import GamePaths


class Crate(ursina.Entity):
class Crate(Entity):

def __init__(self, position):
super().__init__(
Expand All @@ -21,7 +21,7 @@ def __init__(self, position):
self.contents = []
self.is_crate = True
self.texture.filtering = None
self.collider = ursina.BoxCollider(self, size=ursina.Vec3(1, 2, 1))
self.collider = BoxCollider(self, size=Vec3(1, 2, 1))
for i in range (1, random.randint(2, 4)):
self.contents.append(random.choice(items_list))

Expand Down
64 changes: 32 additions & 32 deletions vitrix/lib/entities/enemy.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import ursina
from vitrix_engine import *
import random

zombie_names=["Peter","Harry","Sayed","Usman","Gopal","Ryan","Gerald","James","Robert","Frank","Leon","Jordan","Russell","Johny","Ankur","Carl","Suresh"]

class Enemy(ursina.Entity):
def __init__(self, position: ursina.Vec3, identifier: str, username: str):
class Enemy(Entity):
def __init__(self, position: Vec3, identifier: str, username: str):
super().__init__(
position=position,
model="cube",
origin_y=-0.5,
collider="box",
texture="white_cube",
color=ursina.color.color(0, 0, 1),
scale=ursina.Vec3(1, 2, 1)
color=color.color(0, 0, 1),
scale=Vec3(1, 2, 1)
)
self.gun = ursina.Entity(
self.gun = Entity(
parent=self,
position=ursina.Vec3(0.55, 0.5, 0.6),
scale=ursina.Vec3(0.1, 0.2, 0.65),
position=Vec3(0.55, 0.5, 0.6),
scale=Vec3(0.1, 0.2, 0.65),
model="cube",
texture="white_cube",
color=ursina.color.color(0, 0, 0.4)
color=color.color(0, 0, 0.4)
)

self.name_tag = ursina.Text(
self.name_tag = Text(
parent=self,
text=username,
position=ursina.Vec3(0, 1.3, 0),
scale=ursina.Vec2(5, 3),
position=Vec3(0, 1.3, 0),
scale=Vec2(5, 3),
billboard=True,
origin=ursina.Vec2(0, 0)
origin=Vec2(0, 0)
)

self.is_enemy = True
Expand All @@ -45,36 +45,36 @@ def update(self):
self.health = 100
color_saturation = 1 - self.health / 100

self.color = ursina.color.color(0, color_saturation, 1)
self.color = color.color(0, color_saturation, 1)

if self.health <= 0:
ursina.destroy(self)
destroy(self)


class Zombie(ursina.Entity):
def __init__(self, position: ursina.Vec3, player):
class Zombie(Entity):
def __init__(self, position: Vec3, player):
super().__init__(
position=position,
model="cube",
origin_y=-0.5,
collider="box",
texture="white_cube",
color=ursina.color.color(0, 0, 1),
scale=ursina.Vec3(1, 2, 1)
color=color.color(0, 0, 1),
scale=Vec3(1, 2, 1)
)

self.growl = ursina.Audio("zombie_growl")
self.growl = Audio("zombie_growl")
self.growl.loop = True
self.growl.volume = 0.5
self.growl.play()

self.name_tag = ursina.Text(
self.name_tag = Text(
parent=self,
text=random.choice(zombie_names), #Random zombie names
position=ursina.Vec3(0, 1.3, 0),
scale=ursina.Vec2(5, 3),
position=Vec3(0, 1.3, 0),
scale=Vec2(5, 3),
billboard=True,
origin=ursina.Vec2(0, 0)
origin=Vec2(0, 0)
)

self.is_enemy = True
Expand All @@ -91,27 +91,27 @@ def update(self):
self.health = 30
color_saturation = 1 - self.health / 30

self.color = ursina.color.color(0, color_saturation, 1)
self.color = color.color(0, color_saturation, 1)


dist = ursina.distance_xz(self.player.position, self.position)
dist = distance_xz(self.player.position, self.position)
if dist > 40:
pass

self.look_at_2d(self.player.position, 'y')
hit_info = ursina.raycast(self.world_position + ursina.Vec3(0,1,0), self.forward, 30, ignore=(self,))
hit_info = raycast(self.world_position + Vec3(0,1,0), self.forward, 30, ignore=(self,))
if hit_info.entity == self.player:
if dist > 1.5:
self.position += self.forward * ursina.time.dt * 2
self.position += self.forward * time.dt * 2
else:
self.player.health -= 10
ursina.Audio("hurt").play()
self.position += self.forward * ursina.time.dt * -150
Audio("hurt").play()
self.position += self.forward * time.dt * -150


if self.health <= 0:
self.growl.stop()
ursina.Audio("splat").play()
ursina.destroy(self)
Audio("splat").play()
destroy(self)


10 changes: 5 additions & 5 deletions vitrix/lib/entities/floor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import ursina
from vitrix_engine import *


class FloorCube(ursina.Entity):
class FloorCube(Entity):
base_dir = os.path.join("assets","textures")
def __init__(self, position):
super().__init__(
Expand All @@ -23,12 +23,12 @@ def __init__(self):
dark2 = not dark1

for x in range(-18, 28, 2):
cube = FloorCube(ursina.Vec3(x, 0, z))
cube = FloorCube(Vec3(x, 0, z))

if dark2:
cube.color = ursina.color.color(0, 0.2, 0.8)
cube.color = color.color(0, 0.2, 0.8)
else:
cube.color = ursina.color.color(0, 0.2, 1)
cube.color = color.color(0, 0.2, 1)

dark2 = not dark2

Expand Down
12 changes: 6 additions & 6 deletions vitrix/lib/entities/map.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import ursina
from vitrix_engine import *

from lib.paths import GamePaths
from lib.entities.crate import Crate


class Wall(ursina.Entity):
class Wall(Entity):
base_dir = os.path.join("assets","textures")
def __init__(self, position):
super().__init__(
Expand All @@ -17,14 +17,14 @@ def __init__(self, position):
)

self.texture.filtering = None
self.collider = ursina.BoxCollider(self, size=ursina.Vec3(1, 2, 1))
self.collider = BoxCollider(self, size=Vec3(1, 2, 1))


class Map(ursina.Entity):
class Map(Entity):
def __init__(self):
super().__init__(
model=os.path.join(GamePaths.models_dir, "map1.obj"),
scale=0.3
)
self.collider = ursina.MeshCollider(self)
self.crate_one = Crate(position=ursina.Vec3(10, 1, -5))
self.collider = MeshCollider(self)
self.crate_one = Crate(position=Vec3(10, 1, -5))
Loading