Checkpoint
10
Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
EXEC = asset
|
||||
|
||||
all: $(EXEC)
|
||||
|
||||
asset: clean
|
||||
mkdir assets
|
||||
$(MAKE) -C assets_sources
|
||||
|
||||
clean:
|
||||
rm -r assets
|
BIN
assets/planet/end/00001.png
Normal file
After Width: | Height: | Size: 284 B |
BIN
assets/planet/loop/00001.png
Normal file
After Width: | Height: | Size: 284 B |
BIN
assets/planet/setup/00001.png
Normal file
After Width: | Height: | Size: 284 B |
BIN
assets/ship.gif
Before Width: | Height: | Size: 983 B |
BIN
assets/ship.xcf
BIN
assets/ship/loop/00001.png
Normal file
After Width: | Height: | Size: 329 B |
BIN
assets/ship_fire/end/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_fire/loop/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_fire/setup/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_fire_thrust/end/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_fire_thrust/loop/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_fire_thrust/setup/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_thrust/end/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_thrust/loop/00001.png
Normal file
After Width: | Height: | Size: 490 B |
BIN
assets/ship_thrust/setup/00001.png
Normal file
After Width: | Height: | Size: 490 B |
5
assets_sources/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
TARGETS = planet ship ship_fire ship_fire_thrust ship_thrust
|
||||
EXEC = sub
|
||||
all: $(EXEC)
|
||||
sub:
|
||||
bash target.sh
|
1
assets_sources/planet/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../in_Makefile
|
Before Width: | Height: | Size: 983 B After Width: | Height: | Size: 1003 B |
1
assets_sources/ship/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../in_Makefile
|
BIN
assets_sources/ship/loop.gif
Normal file
After Width: | Height: | Size: 229 B |
BIN
assets_sources/ship/ship.xcf
Normal file
1
assets_sources/ship_fire/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../in_Makefile
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
BIN
assets_sources/ship_fire/loop.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
assets_sources/ship_fire/setup.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
1
assets_sources/ship_fire_thrust/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../in_Makefile
|
BIN
assets_sources/ship_fire_thrust/end.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
assets_sources/ship_fire_thrust/loop.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
assets_sources/ship_fire_thrust/setup.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
1
assets_sources/ship_thrust/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../in_Makefile
|
BIN
assets_sources/ship_thrust/end.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
assets_sources/ship_thrust/loop.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
assets_sources/ship_thrust/setup.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
10
assets_sources/target.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
for target in */ ; do
|
||||
mkdir ../assets/$target
|
||||
for gif in $target/*.gif ; do
|
||||
echo $(basename $gif .gif)
|
||||
name=$(basename $gif .gif)
|
||||
mkdir ../assets/$target${name}
|
||||
ffmpeg -i $gif ../assets/$target${name}/%05d.png
|
||||
done
|
||||
done
|
8
logic.py
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Fri Jan 31 21:07:54 2020
|
||||
|
||||
@author: suwako
|
||||
"""
|
||||
|
33
visual.py
@ -30,8 +30,10 @@ class Obj():
|
||||
scaled_pos = scale * (self.mecha.pos - reference + npsize)
|
||||
scaled_dimension = (scale*self.dimension()).astype(int)
|
||||
scaled_image = pygame.transform.scale(self.image, scaled_dimension)
|
||||
scaled_image = pygame.transform.rotate(scaled_image,
|
||||
self.mecha.orientation%360)
|
||||
scaled_position = scaled_image.get_rect()
|
||||
scaled_position.x, scaled_position.y = map(int, scaled_pos)
|
||||
scaled_position.center = tuple(map(int, scaled_pos))
|
||||
screen.blit(scaled_image, scaled_position)
|
||||
|
||||
|
||||
@ -52,7 +54,7 @@ class Planet(Obj):
|
||||
class Player(Obj):
|
||||
def __init__(self, **keyargs):
|
||||
self.mecha = mecha.Player(**keyargs)
|
||||
self.image = pygame.image.load("assets/ship.png").convert_alpha()
|
||||
self.image = pygame.image.load("assets/ship/setup/0").convert_alpha()
|
||||
self.position = self.image.get_rect()
|
||||
|
||||
|
||||
@ -64,18 +66,25 @@ if __name__ == "__main__":
|
||||
TICK_RATE = 60
|
||||
keys = set()
|
||||
tick = (time.time(), time.time(), 0)
|
||||
screen = pygame.display.set_mode(size)
|
||||
elements = [Player(speed=(-5, 10), pos=(10, 1000)), Player()]
|
||||
screen = pygame.display.set_mode(size,
|
||||
flags=pygame.RESIZABLE)
|
||||
elements = [Player(speed=(-5, 30), pos=(10, 1)), Player()]
|
||||
reference = 1
|
||||
joy=[1, 1]
|
||||
while 1:
|
||||
dtick = tick
|
||||
tick = (tick[0], time.time(), int((time.time() - tick[0])*TICK_RATE))
|
||||
dtick = tick[2] - dtick[2]
|
||||
if dtick > 2:
|
||||
print(dtick)
|
||||
for _ in range(dtick):
|
||||
for i in range(dtick):
|
||||
size = pygame.display.get_surface().get_size()
|
||||
for event in pygame.event.get():
|
||||
#print(event.type)
|
||||
if event.type == pygame.VIDEORESIZE:
|
||||
size = width, height = event.size
|
||||
screen =screen = pygame.display.set_mode(size,
|
||||
flags=pygame.RESIZABLE)
|
||||
if event.type == pygame.QUIT: sys.exit()
|
||||
if event.type == pygame.KEYDOWN:
|
||||
keys.update({event.key})
|
||||
@ -86,17 +95,19 @@ if __name__ == "__main__":
|
||||
if event.key in keys:
|
||||
keys.remove(event.key)
|
||||
screen.fill(black)
|
||||
# for key in keys:
|
||||
# if key in [275,276,273,274]:
|
||||
# exec("camera" + ("[0]+","[0]-","[1]-","[1]+")[[275,276,273,274].index(key)] + "=30")
|
||||
for key in keys:
|
||||
if key in [275,276,273,274]:
|
||||
exec("joy" + ("[0]+","[0]-","[1]+","[1]-")[[275,276,273,274].index(key)] + "=1")
|
||||
elements[1].mecha.orientation=joy[0]*(-3)
|
||||
for element in elements[::-1]:
|
||||
element.mecha.apply_gravity([element.mecha for element in elements])
|
||||
element.mecha.tick(origin=elements[0].mecha.pos)
|
||||
for element in elements:
|
||||
element.draw(scale=.1, reference=elements[1].mecha.pos, size=size)
|
||||
if i <= 2:
|
||||
for element in elements:
|
||||
element.draw(scale=10**(joy[1]*0.05), reference=elements[1].mecha.pos, size=screen.get_size())
|
||||
pygame.display.flip()
|
||||
# for element in elements:
|
||||
# element.apply(camera=camera, origin=origin)
|
||||
# screen.blit(element.image, element.position)
|
||||
pygame.display.flip()
|
||||
time.sleep(0.001)
|
||||
if tick[2]%60 == 0 : print(elements[1].mecha.pos)
|