Skip to content

Releases: skifans/CCRPG

V2.2

18 Mar 16:07

Choose a tag to compare

#Map

#Imports
import pygame, random, time, os, ctypes
from pygame.locals import *
from tkinter import *

#Colour Grid
WHITE = (255, 255, 255)
BLACK = ( 0, 0, 0)
RED = (255, 0, 0)
DARKPINK = (255, 20, 147)
GREEN = ( 0, 255, 0)
DARKGREEN = ( 0, 155, 0)
ORANGE = (255, 153, 18)
DARKGRAY = ( 40, 40, 40)
YELLOW = (255, 255, 0)
BLUE = ( 0, 0, 255)
KHAKI = (139, 134, 78)

windowWidth = 800
windowHeight = 600
lineColour = WHITE
cellSize = 20
assert windowHeight % cellSize == 0
assert windowWidth % cellSize == 0
cellWidth = int(windowWidth / cellSize)
cellHeight = int(windowHeight / cellSize)

pygame.init()

#Initiate the window and the basic grid background when called.
def drawGrid():
global window
window = pygame.display.set_mode((windowWidth, windowHeight))
for x in range(0, windowWidth, cellSize): # draw vertical lines
pygame.draw.line(window, lineColour, (x, 0), (x, windowHeight))
for y in range(0, windowHeight, cellSize): # draw horizontal lines
pygame.draw.line(window, lineColour, (0, y), (windowWidth, y))
pygame.display.update() #removing this will make grid and loading appear at the same time

class textures():

waterCoords = []
lavaCoords = []
roadCoords = []

def __init__(self):
    self.x = 0
    self.y = 0

class playertTexture():

    x = 0
    y = 0

    def loadTextures(self, x, y):
        self.texture = pygame.image.load(os.path.join("textures","necromancer.png"))
        self.texturerect = self.texture.get_rect()
        self.coords = (x, y)
        self.texturerect.move_ip(self.coords)
        window.blit(self.texture, self.texturerect)

#Class for the Water Texture
class waterTexture():
    def __init__(self):
        self.y = 0
        self.x = 0

#When Called Loads Texture in Specified Coords
    def loadTexture(self, x, y):
        self.texture = pygame.image.load(os.path.join("textures","waterTexture.gif"))
        self.texturerect = self.texture.get_rect()
        self.coords = (x, y)
        self.texturerect.move_ip(self.coords)
        window.blit(self.texture, self.texturerect)
        #pygame.display.flip()

#Class for General Grass Texture
class grassTexture():
    def __init__(self):
        self.x = 0
        self.y = 0

    def loadTexture(self, x, y):
        self.texture = pygame.image.load(os.path.join("textures","fieldTexture.gif"))
        self.texturerect = self.texture.get_rect()
        self.coords = (x, y)
        self.texturerect.move_ip(self.coords)
        window.blit(self.texture, self.texturerect)
        #pygame.display.flip()

class lavaTexture():
    def __init__(self):
        self.x = 0
        self.y = 0

    def loadTexture(self, x, y):
        self.texture = pygame.image.load(os.path.join("textures","lavaTexture.gif"))
        self.texturerect = self.texture.get_rect()
        self.coords = (x, y)
        self.texturerect.move_ip(self.coords)
        window.blit(self.texture, self.texturerect)
        #pygame.display.flip()

class roadTexture():
    def __init__(self):
        self.x = 0
        self.y = 0

    def loadTexture(self, x, y):
        self.leftTexture = pygame.image.load(os.path.join("textures","leftRoadSegment.png"))
        self.leftTextureRect = self.leftTexture.get_rect()
        self.rightTexture = pygame.image.load(os.path.join("textures","rightRoadSegment.png"))
        self.rightTextureRect = self.rightTexture.get_rect()
        self.leftCoords = (x,y)
        self.rightCoords = ((x+20),y)
        self.leftTextureRect.move_ip(self.leftCoords)
        self.rightTextureRect.move_ip(self.rightCoords)
        window.blit(self.leftTexture, self.leftTextureRect)
        window.blit(self.rightTexture, self.rightTextureRect)
        #pygame.display.flip()

class loadigTexture():
    def __init__(self):
        self.x = 0
        self.y = 0

    def loadTexture(self, x, y):
        self.texture = pygame.image.load(os.path.join("textures","whiteTexture.gif"))
        self.texturerect = self.texture.get_rect()
        self.coords = (x, y)
        self.texturerect.move_ip(self.coords)
        window.blit(self.texture, self.texturerect)
        #pygame.display.flip()

playert = textures.playertTexture()

#Loads vertical line of texture - currently only way of rendering textures for most textures.
#Takes four arguments: 2 coords to print textures between MUST BE VERTICAL STRAIGHT LINE
def loadWaterVertLine(x, y, a, b):
img = textures.waterTexture()
while y < b:
img.loadTexture(x, y)
textures.waterCoords.append((x, y))
y += 20

#Similar to the Vertical Line However MUST BE HORIZONTAL STRAIGHT LINE

def loadWaterHoriLine(x, y, a, b):
img = textures.waterTexture()
while x < a:
img.loadTexture(x, y)
x += 20

def loadGrassVertLine(x, y, a, b):
img = textures.grassTexture()
while y < b:
img.loadTexture(x, y)
textures.waterCoords.append((x, y))
y += 20

def loadLavaVertLine(x, y, a, b):
img = textures.lavaTexture()
while y < b:
img.loadTexture(x, y)
textures.lavaCoords.append((x, y))
y += 20

def loadRoadVertLine(x, y, a, b):
img = textures.roadTexture()
while y < b:
img.loadTexture(x, y)
textures.roadCoords.append((x,y))
y += 20

def loadWhiteVertLine(x, y, a, b):
img = textures.loadigTexture()
while y < b:
img.loadTexture(x, y)
#textures.loadCoords.append((x,y))
y += 20

#Not very clever way of loading all the water textures for the main map...
def loadWaterMap():
#Castle Moat Area
loadWaterVertLine(0, 520, 0, 600)
loadWaterVertLine(20, 480, 20, 600)
loadWaterVertLine(40, 460, 20, 600)
loadWaterVertLine(60, 440, 20, 600)
loadWaterVertLine(80, 440, 20, 600)
loadWaterVertLine(100, 420, 20, 600)
loadWaterVertLine(120, 420, 20, 600)
loadWaterVertLine(140, 420, 20, 600)
loadWaterVertLine(160, 440, 20, 600)
loadWaterVertLine(180, 440, 20, 600)
loadWaterVertLine(200, 460, 20, 600)
loadWaterVertLine(220, 480, 20, 600)
loadWaterVertLine(240, 520, 20, 600)
#Main Sea Water Segment
loadWaterHoriLine(280, 580, 800, 580)
loadWaterHoriLine(300, 560, 800, 560)

def loadLavaMap():
#loadLavaVertLine(400, 200, 400, 300)
#loadLavaVertLine(420, 220, 420, 320)
#Lava Texture Does Not Tessalate
return

def loadRoadMap():
loadRoadVertLine(500, 200, 500, 400)

def loadWhiteMap():
#arial font used
#l
loadWhiteVertLine(40, 220, 60, 360)
#o
loadWhiteVertLine(80, 260, 80, 340)
loadWhiteVertLine(100, 240, 100, 260)
loadWhiteVertLine(100, 340, 100, 360)
loadWhiteVertLine(120, 240, 120, 260)
loadWhiteVertLine(120, 340, 120, 360)
loadWhiteVertLine(140, 240, 140, 260)
loadWhiteVertLine(140, 340, 140, 360)
loadWhiteVertLine(160, 260, 160, 340)
#a
loadWhiteVertLine(200, 260, 200, 280)
loadWhiteVertLine(200, 300, 200, 340)
loadWhiteVertLine(220, 240, 220, 260)
loadWhiteVertLine(220, 280, 220, 300)
loadWhiteVertLine(220, 340, 220, 360)
loadWhiteVertLine(240, 240, 240, 260)
loadWhiteVertLine(240, 280, 240, 300)
loadWhiteVertLine(240, 340, 240, 360)
loadWhiteVertLine(260, 240, 260, 260)
loadWhiteVertLine(260, 280, 260, 300)
loadWhiteVertLine(260, 320, 260, 340)
loadWhiteVertLine(280, 260, 280, 360)
#d
loadWhiteVertLine(320, 260, 320, 340)
loadWhiteVertLine(340, 240, 340, 260)
loadWhiteVertLine(340, 340, 340, 360)
loadWhiteVertLine(360, 240, 360, 260)
loadWhiteVertLine(360, 340, 360, 360)
loadWhiteVertLine(380, 260, 380, 280)
loadWhiteVertLine(380, 320, 380, 340)
loadWhiteVertLine(400, 200, 400, 360)
#i
loadWhiteVertLine(440, 200, 440, 220)
loadWhiteVertLine(440, 240, 440, 360)
#n
loadWhiteVertLine(480, 240, 480, 360)
loadWhiteVertLine(500, 240, 500, 260)
loadWhiteVertLine(520, 240, 520, 260)
loadWhiteVertLine(540, 240, 540, 260)
loadWhiteVertLine(560, 260, 560, 360)
#g
loadWhiteVertLine(600, 260, 600, 340)
loadWhiteVertLine(600, 380, 600, 400)
loadWhiteVertLine(620, 240, 620, 260)
loadWhiteVertLine(620, 340, 620, 360)
loadWhiteVertLine(620, 380, 620, 400)
loadWhiteVertLine(640, 240, 640, 260)
loadWhiteVertLine(640, 340, 640, 360)
loadWhiteVertLine(640, 380, 640, 400)
loadWhiteVertLine(660, 260, 660, 280)
loadWhiteVertLine(660, 320, 660, 340)
loadWhiteVertLine(660, 380, 660, 400)
loadWhiteVertLine(680, 240, 660, 380)

#Fills Background With Grass
def fillGrass(playert_x, playert_y):
x=0
#while x < windowWidth:
loadGrassVertLine(playert_x-20,playert_y-20,playert_x-20,playert_y+20) #refresh 1 collum to the left, from playert y -20 to playert y +20
loadGrassVertLine(playert_x,playert_y-20,playert_x,playert_y+40) #not sure way this needs to be 40, but dosnt work otherwise, refreshes collum you are in
loadGrassVertLine(playert_x+20,playert_y-20,playert_x+20,playert_y+20) #refresh 1 collum to the right, same range as top
#x += 20

def fillGrass_first_time():
x=0
while x < windowWidth:
loadGrassVertLine(x,0,x,windowHeight)
x += 20

#Refresh Textures Will Take Current Logged Appropriate Coords For Each Texture & Re-Render It (Pre-".flip")
def refreshTextures(texture, coords):
img = texture()
for i in coords:
img.loadTexture(i[0], i[1])

def refreshAllTextures():
refreshTextures(textures.roadTexture, textures.roadCoords)
loadWaterMap()
refreshTextures(textures.lavaTexture, textures.lavaCoords)
playert.loadTextures(playert.x, playert.y)

#General "Main-loop" equivalent for testing.
def loadTextures():
drawGrid()
loadWhiteMap()
pygame.display.flip()
#time.sleep(3) #this will keep the loading screen on for an extra 3 seconds
fillGrass_first_time()
loadWaterMap()
loadLavaMap()
loadRoadMap()
pygame...

Read more

V2.1

16 Mar 11:00

Choose a tag to compare

V2.1 Pre-release
Pre-release

Menu added

V2

16 Mar 10:30

Choose a tag to compare

V2 Pre-release
Pre-release

Combat system has been merged with map

Combat V0.9

16 Mar 09:41

Choose a tag to compare

Combat V0.9 Pre-release
Pre-release

Update to combat system:
Better handling of errors - system will deal with the user typing in an incorrect player class
Combat system updated to use the combat() function - call this to initiate the combat system.