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
|
# 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 network import startServer
|
||||||
|
from player import Player
|
||||||
|
from block import Block
|
||||||
from world import *
|
from world import *
|
||||||
from config import *
|
from config import *
|
||||||
|
|
||||||
|
|
||||||
|
def current_milli_time():
|
||||||
|
return round(time.time() * 1000)
|
||||||
|
|
||||||
async def tickTimer():
|
async def tickTimer():
|
||||||
while True:
|
while True:
|
||||||
for b in WORLD:
|
for b in WORLD:
|
||||||
await b.tick()
|
await b.tick()
|
||||||
await asyncio.sleep(1/20)
|
await asyncio.sleep(1/20)
|
||||||
|
|
||||||
|
async def keepAliveTimer():
|
||||||
|
while True:
|
||||||
|
for b in getPlayers():
|
||||||
|
await b.keepAlive()
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def renderTimer():
|
async def renderTimer():
|
||||||
while True:
|
while True:
|
||||||
for p in getPlayers():
|
for p in getPlayers():
|
||||||
|
@ -19,6 +30,7 @@ async def renderTimer():
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
asyncio.get_event_loop().create_task(tickTimer())
|
asyncio.get_event_loop().create_task(tickTimer())
|
||||||
|
asyncio.get_event_loop().create_task(keepAliveTimer())
|
||||||
asyncio.get_event_loop().create_task(renderTimer())
|
asyncio.get_event_loop().create_task(renderTimer())
|
||||||
await startServer(HOST, PORT)
|
await startServer(HOST, PORT)
|
||||||
|
|
||||||
|
|
|
@ -231,13 +231,25 @@ class Player(Block):
|
||||||
|
|
||||||
async def onCollide(self, player, x, y):
|
async def onCollide(self, player, x, y):
|
||||||
await super().onCollide(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):
|
async def render(self):
|
||||||
self.vel_x *= 0.5
|
self.vel_x *= 0.5
|
||||||
self.vel_y *= 0.5
|
self.vel_y *= 0.5
|
||||||
self.x += self.vel_x
|
self.x += self.vel_x
|
||||||
self.y += self.vel_y
|
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
|
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):
|
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}"
|
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