Skip to content

Commit 45ba85d

Browse files
author
p.witvoet
committed
- added various new transition tiles
- added factory and headquarters sprites
1 parent 9928c48 commit 45ba85d

26 files changed

+36
-11
lines changed

run server.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ TITLE AI Wars - Server
22

33
CD source
44

5-
run_server.py localhost 7777 test_level.py aiwars.py
5+
run_server.py localhost 7777 mirror_islands.py aiwars.py
66

77
PAUSE

source/visualization/gameScreen.py

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pygame
23
from core.point import *
34
from tilemap import *
45
from spriteCollection import *
@@ -12,7 +13,16 @@ def __init__(self, game, imageCache, screenDimension):
1213
self.screenDimension = screenDimension
1314

1415
self.cameraMouseOffset = Point(0, 0)
15-
self.rightMouseButtonDown = False
16+
self.cameraDragging = False
17+
self.arrowKeyState = {pygame.constants.K_UP: False, \
18+
pygame.constants.K_DOWN: False, \
19+
pygame.constants.K_LEFT: False, \
20+
pygame.constants.K_RIGHT: False}
21+
self.arrowKeyMovement = {pygame.constants.K_UP: Point(0, 1), \
22+
pygame.constants.K_DOWN: Point(0, -1), \
23+
pygame.constants.K_LEFT: Point(1, 0), \
24+
pygame.constants.K_RIGHT: Point(-1, 0)}
25+
self.arrowKeyMovementSpeed = 32
1626

1727
self.drawGrid = True
1828

@@ -27,34 +37,41 @@ def __init__(self, game, imageCache, screenDimension):
2737
def onKeyDown(self, key):
2838
if key == ord('g'):
2939
self.drawGrid = not self.drawGrid
40+
elif self.arrowKeyState.has_key(key):
41+
self.arrowKeyState[key] = True
3042
#
3143

3244
def onKeyUp(self, key):
33-
pass
45+
if self.arrowKeyState.has_key(key):
46+
self.arrowKeyState[key] = False
3447
#
3548

3649
def onMouseDown(self, button, position):
3750
if button == 3: # Right mouse button, TODO: Look for pygame constants for this?
3851
self.cameraMouseOffset.x = self.camera.x - position[0]
3952
self.cameraMouseOffset.y = self.camera.y - position[1]
40-
self.rightMouseButtonDown = True
53+
self.cameraDragging = True
4154
#
4255

4356
def onMouseUp(self, button, position):
4457
if button == 3:
45-
self.rightMouseButtonDown = False
58+
self.cameraDragging = False
4659
#
4760

4861
def onMouseMove(self, position):
49-
if self.rightMouseButtonDown:
62+
if self.cameraDragging:
5063
self.camera.x = position[0] + self.cameraMouseOffset.x
5164
self.camera.y = position[1] + self.cameraMouseOffset.y
5265

5366
self.clampCameraToLevel()
5467
#
5568

5669
def update(self):
57-
pass
70+
if not self.cameraDragging:
71+
for key in self.arrowKeyState.keys():
72+
if self.arrowKeyState[key]:
73+
self.camera += self.arrowKeyMovement[key] * self.arrowKeyMovementSpeed
74+
self.clampCameraToLevel()
5875
#
5976

6077
def draw(self, screen):

texture source/process.bat

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ REM to_tiles takes the following arguments: [output folder] [spritesheet] [type]
22
REM This doesn't generate every single tile, but it surely speeds up things
33

44
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "sea_river.png" 3 3,4 1 16 16
5-
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "river_plains.png" 1 1,4 0,2,5 16 16
65
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "road_plains.png" 5 4,5 0,1,2,3 16 16
7-
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "bridge_river.png" 4 4,5 1 16 16
8-
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "bridge_sea.png" 4 4,5 3 16 16
6+
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "river_plains.png" 1 1,4 0,2,5 16 16
7+
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "bridge_river.png" 4 1,4,5 1 16 16
8+
"../tools/to_tiles.py" "%~dp0\../textures/terrain/tiles/" "bridge_sea.png" 4 1,4,5 3 16 16
99

1010
PAUSE
388 Bytes
Loading
381 Bytes
Loading

textures/terrain/sprites/spriterules.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,12 @@
2929
rules.setSpriteCount('City', 3, 5)
3030
rules.addRule('City', 'apartment_1.png', ( 0, 8, 16, 11))
3131
rules.addRule('City', 'apartment_2.png', ( 0, 5, 9, 15))
32-
rules.addRule('City', 'apartment_3.png', ( 0, 8, 10, 9))
32+
rules.addRule('City', 'apartment_3.png', ( 0, 8, 10, 9))
33+
34+
# Base
35+
rules.setSpriteCount('Base', 1, 1)
36+
rules.addRule('Base', 'factory_1.png', ( 0, 0, 32, 32))
37+
38+
# Headquarters
39+
rules.setSpriteCount('Headquarters', 1, 1)
40+
rules.addRule('Headquarters', 'headquarters_1.png', ( 0, 16, 32, 32))
1006 Bytes
Loading
990 Bytes
Loading
1018 Bytes
Loading
1002 Bytes
Loading
1020 Bytes
Loading
1 KB
Loading
984 Bytes
Loading
1009 Bytes
Loading
1010 Bytes
Loading
1002 Bytes
Loading
1 KB
Loading
999 Bytes
Loading
1000 Bytes
Loading
1006 Bytes
Loading
1022 Bytes
Loading
1000 Bytes
Loading
993 Bytes
Loading
1018 Bytes
Loading
1019 Bytes
Loading
1004 Bytes
Loading

0 commit comments

Comments
 (0)