0% found this document useful (0 votes)
27 views6 pages

Cały Kod Game Dev2 Code Combat

The document outlines the creation of a game featuring a player character, various enemies, traps, and a boss encounter. It includes detailed instructions for spawning game elements, managing health and collectibles, and implementing game mechanics such as traps and boss activation. The gameplay involves collecting items, defeating enemies, and rescuing a hostage while navigating through a designed world.

Uploaded by

Marcin B Ziip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views6 pages

Cały Kod Game Dev2 Code Combat

The document outlines the creation of a game featuring a player character, various enemies, traps, and a boss encounter. It includes detailed instructions for spawning game elements, managing health and collectibles, and implementing game mechanics such as traps and boss activation. The gameplay involves collecting items, defeating enemies, and rescuing a hostage while navigating through a designed world.

Uploaded by

Marcin B Ziip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

# Create your own game!

# Spawn a player with spawnPlayerXY()


# Add at least one goal!
# Spawn objects into the game with spawnXY()

####### WORLD ########

# spawn player
player = game.spawnPlayerXY("duelist", 8, 6)

player.maxHealth = 2000
player.maxSpeed = 10
player.attackDamage = 20
player.scale = 1

#Trap corridor
game.spawnXY("forest", 18, 9)
game.spawnXY("forest", 18, 18)
game.spawnXY("forest", 18, 22)
game.spawnXY("forest", 18, 27)
game.spawnXY("forest", 20, 32)
game.spawnXY("forest", 25, 33)
game.spawnXY("forest", 18, 48)
game.spawnXY("forest", 26, 48)
game.spawnXY("forest", 33, 38)
game.spawnXY("forest", 33, 47)
L1 =game.spawnXY("lightstone", 25, 41)

# TRAP itself

bait = game.spawnXY("chest", 9, 37)


bait.value = 0

#Enemies Attacking
spawn1 = game.spawnXY("generator", 46, 55)
spawn1.maxHealth = 200
spawn1.spawnType = "munchkin"
spawn1.spawnDelay = 200
spawn1.spawnAI = "AttacksNearest"

# create fortess
game.spawnXY("fence", 55, 5)
game.spawnXY("fence", 55, 10)
game.spawnXY("fence", 55, 15)
game.spawnXY("fence", 55, 20)
game.spawnXY("fence", 55, 25)
game.spawnXY("fence", 58, 25)
game.spawnXY("fence", 72, 25)
game.spawnXY("fence", 73, 25)

#lock hostage
GateWay1 = game.spawnXY("silver-chest", 65, 25)
GateWay2 = game.spawnXY("silver-chest", 64, 25)
GateWay3 = game.spawnXY("silver-chest", 61, 25)
GateWay4 = game.spawnXY("silver-chest", 68, 25)
GateWay5 = game.spawnXY("silver-chest", 66, 25)
lock = game.spawnXY("locked-chest", 65, 25)
# Evacuation corridor

game.spawnXY("forest", 31, 7)
game.spawnXY("forest", 31, 15)
game.spawnXY("forest", 31, 22)
game.spawnXY("forest", 47, 7)
game.spawnXY("forest", 47, 15)
game.spawnXY("forest", 47, 22)

EvacPoint = game.spawnXY("x-mark-stone", 39, 7)

# create Boss
boss = game.spawnXY("ogre-f", 63, 20)
boss.maxHealth = 3000
boss.attackDamage = 40

# Exit and the hostage


exit = game.spawnXY("x-mark-bones", 65, 25)
game.spawnXY("x-mark-bones", 60, 7)
game.spawnXY("x-mark-bones", 62, 8)
game.spawnXY("x-mark-bones", 67, 6)
game.spawnXY("x-mark-bones", 72, 20)
xmark = game.spawnXY("x-mark-bones", 70, 11)
hostage1 = game.spawnXY("peasant", 67, 19)
hostage1.maxHealth = 5000

###### FUNCTIONS AND EVENTS ##########

# Health and Time

def healthLeft(event):
db.set("health", player.health)
ui.track(db, "health")

game.on("update", healthLeft)
ui.track(game, "time")

# Collecting

db.set("Gold", 0)
ui.track(db, "Gold")
def collected(event):
collector = event.target
item = event.other
if item.type == "gold-coin":
db.add("Gold", item.value)
if item.type == "mushroom":
FunnyHostage()
strong()

if item == lock:
unlock()

if item == bait:
TrapTriger()

# Trap triger
def TrapTriger():
player.say("OH NO, IT'S A TRAP")
S1 = game.spawnXY("skeleton", 6, 41)
S1.maxHealth = 300
S1.attackDamage = 50
S1.attack(player)
ogr =game.spawnXY("ogre", 9, 30)
ogr.maxHealth = 200
ogr.attack(player)
game.spawnXY("thrower", 7, 55)
game.spawnXY("thrower", 11, 55)
game.spawnXY("thrower", 7, 15)
game.spawnXY("thrower", 11, 15)
while True:
if player.distanceTo(S1) > 10:
S1.attack(player)

# Throwers behavior on spawn event ( on "AttackNearest" thye would attack skeleton)

def attackingHero(event):
while True:
unit = event.target
if player:
unit.attack(player)

# drop some health potion and gold after geting away from the trap

def dropPotion(event):
unit = event.target
x= unit.pos.x -3
y= unit.pos.y +2
potion1 = game.spawnXY("potion-large", x, y)
potion2 = game.spawnXY("potion-large", x, y)
potion1.value = 0
potion2.value = 0

def dropGold(event):
unit = event.target
x= unit.pos.x +3
y= unit.pos.y +3
coin1 = game.spawnXY("gold-coin", x, y)
coin1.value = 1

# Generator activation

def NotToClose():
while True:
if player.distanceTo(spawn1) < 20:
spawn1.spawnDelay = 2

# lets add some special effects

def FireWorksAndKey(event):
unit = event.target
game.spawnXY("fire-trap", 45, 60)
game.spawnXY("fire-trap", 47, 58)
game.spawnXY("munchkin", 45, 60)
game.spawnXY("munchkin", 46, 58)
dumy1 = game.spawnXY("scout", 47, 58)
dumy1.moveXY(45, 60)
#Need a key? Lets spawn it after FireWorks cool down.
ui.track(game, "KeySpawnIn")
db.set("EventTime", game.time)
while True:
game.KeySpawnTime = 8
game.KeySpawnIn = game.KeySpawnTime + db.EventTime - game.time
if game.KeySpawnIn <= 0:
key = game.spawnXY("silver-key", 43, 57)
break

#unlock hostage

def unlock(event):
GateWay1.destroy()
GateWay2.destroy()
GateWay3.destroy()
GateWay4.destroy()
GateWay5.destroy()
boss.say("Who disturbs my eating time")
boss.attack(player)
bossAttack()

# Boss Activation

def bossAttack():
ui.track(game, "FireOn")
db.set("EvTime3", game.time)
game.FireOn = 0
db.set("FireOn", game.FireOn)
game.on("update", BossHealth)
while True:
if player.health <= 500:
hostage1.say("HANG ONNNN!!")
hostage1.moveXY(65, 25)
boost1 = game.spawnXY("mushroom", player.pos.x +3, player.pos.y +3)
hostage1.say("HERE, HAVE IT, QUICKLY!!!")
break
else:

if game.FireOn ==0:
game.FireTime = 0
game.FireTime = game.FireTime +10
game.FireOn = db.EvTime3 + game.FireTime - game.time
if game.FireOn ==5:
boss.say("YOU GONNA EXPLODE")
boss.health + 50
game.spawnXY("fire-trap", player.pos.x, player.pos.y)
if game.FireOn ==0:
boss.say("GET OVER HERE")
bossAttack()
# BOSS Health
def BossHealth(event):
db.set("BossHealth", boss.health)
ui.track(db, "BossHealth")

## Mushroom boost

def strong():
db.set("EvTime", game.time)
ui.track(game, "BoostTime")
player.maxSpeed +=10
player.attackDamage +=100
player.maxHealth = 3000
player.health += 1000
player.scale = 2
while True:
game.BoostDuration = 15
game.BoostTime = game.BoostDuration + db.EvTime - game.time
if game.BoostTime <= 0:
player.maxSpeed -= 10
player.attackDamage -= 20
player.scale = 1
break

# create hostage sytuation

def FunnyHostage():
boss.say("WHAT IS THIS? GET BACK TO YOUR CAGE!")
boss.moveXY(hostage1.pos.x +2, hostage1.pos.y +2)
hostage1.moveXY(73, 8)
boss.attack(player)

# After DEFEATING BOSS

def hostage(event):
unit = event.target
hostage1.say("IM STILL SHAKING WITH FEAR")
hostage1.moveXY(71, 8)

while True:
if player.distanceTo(xmark) <=1:
player.say("COM WITH ME IF YOU WANT TO LIVE")
hostage1.on("hear", fallowHero)

# HAPPY END
def fallowHero (event):
while True:
hostage1.moveXY(player.pos.x +2, player.pos.y +2)

###### GAME-PLAY ######

player.on("collect", collected)

game.setActionFor("thrower", "spawn", attackingHero)


game.setActionFor("thrower", "defeat", dropGold)
game.setActionFor("munchkin", "defeat", dropGold)
game.setActionFor("skeleton", "defeat", dropPotion)

spawn1.on("defeat", FireWorksAndKey)

while True:
if game.time ==1:
player.say("King ordered me to find his Alchemist's")
if game.time ==3:
player.say("Where can he be ??")
if game.time ==4:
hostage1.say("HELP, HELP, HE WANT'S TO EAT ME!")
if game.time ==5:
boss.say("NO ONE CAN HEAR YOU HERE")
break

while True:
if player.distanceTo(spawn1) <30:
hostage1.say("HELP, IM OVER HERE")
if player.distanceTo(spawn1) <22:
boss.say("BE QUIET, GET HIM !!")
break

while True:
if player.distanceTo(spawn1) < 20:
spawn1.spawnDelay = 2

if boss.health <= 110:


player.say("BE GONE !!!")
player.cleave(boss)
break

boss.on("defeat", hostage)

You might also like