Compare commits
No commits in common. "main" and "0.1.0" have entirely different histories.
11 changed files with 26 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
# cubicjs
|
||||
|
||||
сайт: https://meex.lol/cubic/client/index.html
|
||||
сайт: https://meex.lol/cubic/
|
||||
|
||||
## роадмап
|
||||
|
||||
|
|
0
build.sh → client/build.sh
Normal file → Executable file
0
build.sh → client/build.sh
Normal file → Executable file
|
@ -1,16 +1,27 @@
|
|||
|
||||
import asyncio
|
||||
import asyncio, time
|
||||
from network import startServer
|
||||
from player import Player
|
||||
from block import Block
|
||||
from world import *
|
||||
from config import *
|
||||
|
||||
|
||||
def current_milli_time():
|
||||
return round(time.time() * 1000)
|
||||
|
||||
async def tickTimer():
|
||||
while True:
|
||||
for b in WORLD:
|
||||
await b.tick()
|
||||
await asyncio.sleep(1/20)
|
||||
|
||||
async def keepAliveTimer():
|
||||
while True:
|
||||
for b in getPlayers():
|
||||
await b.keepAlive()
|
||||
await asyncio.sleep(1)
|
||||
|
||||
async def renderTimer():
|
||||
while True:
|
||||
for p in getPlayers():
|
||||
|
@ -19,6 +30,7 @@ async def renderTimer():
|
|||
|
||||
async def main():
|
||||
asyncio.get_event_loop().create_task(tickTimer())
|
||||
asyncio.get_event_loop().create_task(keepAliveTimer())
|
||||
asyncio.get_event_loop().create_task(renderTimer())
|
||||
await startServer(HOST, PORT)
|
||||
|
||||
|
|
|
@ -231,13 +231,25 @@ class Player(Block):
|
|||
|
||||
async def onCollide(self, player, x, y):
|
||||
await super().onCollide(player, x, y)
|
||||
# if x != 0:
|
||||
# player.vel_x *= 0.5
|
||||
# self.vel_x = player.vel_x
|
||||
# if y != 0:
|
||||
# player.vel_y *= 0.5
|
||||
# self.vel_y = player.vel_y
|
||||
# pass
|
||||
|
||||
async def render(self):
|
||||
self.vel_x *= 0.5
|
||||
self.vel_y *= 0.5
|
||||
self.x += self.vel_x
|
||||
self.y += self.vel_y
|
||||
# await self.setVel(self.vel_x * 0.5, self.vel_y * 0.5)
|
||||
# await self.setPos(self.x + self.vel_x, self.y + self.vel_y)
|
||||
return self.vel_x != 0 or self.vel_y != 0
|
||||
|
||||
async def keepAlive(self):
|
||||
await self.sendPacket("R", [str(self.x), str(self.y), str(self.vel_x), str(self.vel_y)])
|
||||
|
||||
def toStatement(self, add=True):
|
||||
return f"P1{self.name},{self.x},{self.y},{self.vel_x},{self.vel_y},{self.color}" if add else f"P0{self.name}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue