Skip to content
TheScrawl edited this page Jul 5, 2018 · 2 revisions

Welcome to the ncpyrpg wiki! Here, we are aiming to document fully how to use ncpyrpg to make and play games.

Running a game

Running a game is easy, you will need the gamefile and functionfile in the same directory as ncpyrpg (with no other gamefiles present)

Making a Game

Games are made using a number of components:

Map Arrays:

Map arrays are non-interactive world objects - walls, buildings etc

They are defined using lists:

box = ['##########',
       '#        #',
       '#        #',
       '#        #',
       '#        #',
       '##########'.]

Map Objects

Map objects are interactive world objects that do things when touched - buttons, traps etc

They are defined using the mapObj class

button = mapObj(
	['x'], #Character that will be printed, must be a list
	5, #Y Coordinate
	5, #X Coordinate

        # Function list; list of different functions that will be executed
        # Will be executed in order
	[
	    'menuOut("button pressed", menuWindow)',
	    'window.addch(7, 6, " ")', 
        ]
)

Using the objects

Once you have defined the objects you want to use, you must add them to the drawmap() function using drawArray()

drawArray() takes 4 parameters: Y coord, X coord, window to print to (should be just window in most scenarios), and which array to print

def drawmap(window):
	drawArray(1, 1, window, box) #Y coord, X coord, window (essential, don't change), and array to print
        drawArray(button.posY, button.posX, window, button.char) #map objects should follow this format

Once this is done, you will also need to add each imported object to the varList, this is important for when the engine loads the game data. There should also be some other variables in there already, don't touch those

varList = ['mapObjList', 'gameWindowXSize', 'gameWindowYSize', 'playerY', 'playerX', 'box', 'button']

Game Variables:

You will also need to set a few variables that impact the game:

#Player original spawn point
playerY = 4
playerX = 4

#Game window size 
#Make sure this is big enough to fit all the things you want to print, or you will get errors!
gameWindowXSize = 40 
gameWindowYSize = 28
Clone this wiki locally