Code archives/Miscellaneous/Big Bad Dragon

This code has been declared by its author to be Public Domain code.

Download source code

Big Bad Dragon by Techlord2007
A simple Text-based RPG game I wrote in 10 minutes, explaining to a coworker on what inspired me to get into Game Programming. He got a kick out of it, thought you would too.

Hack the code to create your own variations, additions, etc. Have Fun!
Graphics 800,200,32,2
Print "*** Big Bad Dragon ***"
Print
Print "The Big Bad Dragon has kidnapped The Little Princess."
Print "Being the Brave Knight you are, you have tracked" 
Print "down the beast to its Lair. Here the beast snores "
Print "loudly, flames jet out from its nostrils. You use the "
Print "element of suprize to plan your attack... CHARGE!" 
Print

;The Dragon
Type character
	Field name$
	Field health%
	Field weapon%
	Field special%
End Type

player.character = New character
player\name$= Input("Name your Warrior:") 
player\health = 100
player\weapon = 10
player\special = 3

monster.character = New character
monster\name$ = "Dragon"
monster\health="200"
monster\weapon = 5
monster\special = 10

SeedRnd MilliSecs()
;game loop
Repeat

attack=Input("You attack with [1]Sword [2]Magic("+player\special+"): ")

If attack=1 
	playerpower = Rnd(player\weapon)
	success = Rnd(6)
	failed = Rnd(6)
	If success > failed Then 
		Print "Sword does "+playerpower+" points of damage."
		monster\health=monster\health-playerpower
		
		success = Rnd(10)
		failed = Rnd(10) 
		If success>failed Then 
			playerpower = Rnd(25)*2
			Print "You inflicted a Critical Wound for "+playerpower+" points of damage."
			monster\health=monster\health-playerpower
		EndIf
		
	Else
		Print "Your attack failed:("	
	EndIf
	
	If Rnd(12)>Rnd(15)
		Print 
		Print "The Tooth Fairy appears before you."
		Print "She holds a of small pouch of Jellybeans."
		Print "Guess the number of Jellybeans in the bag"
		magicnumber = Input("to be granted a wish: ") 
		If magicnumber>Rnd(38)
			player\special=player\special+1
			Print
			Print "POW!!!! You recieve a Magic Snowball."
		Else 
			Print "You received Didly Squat!"
		EndIf	
	EndIf
	
ElseIf attack=2

	If player\special=0 
		Print "Sorry no Magic"
	Else
		player\special = player\special -1
		playerpower = Rnd(50)
		success = Rnd(6)
		failed = Rnd(6)
		If success > failed Then 
			Print "Snowball does "+playerpower+" points of damage."
			monster\health=monster\health-playerpower
		Else
			Print "Your attack failed:("	
		EndIf 
	EndIf
End If

;Dragon attack
Dragonattack = Rnd(30) 
If Dragonattack > 15

	Dragonweapon = Rnd(1)
	
	If Dragonweapon = 1 
		If monster\special > 0
		
			monsterpower = Rnd(100)
			success = Rnd(6)
			failed = Rnd(6)
			If success > failed Then 
				Print "The Dragon's Bad Breath does "+monsterpower +" points of damage"
				player\health=player\health-monsterpower
			Else
				Print "The Dragon blew steam."	
			EndIf
		
		Else
			Print "The Dragon is out of Breath."
		EndIf
		
	Else 
		monsterpower = Rnd(monster\weapon)
		success = Rnd(6)
		failed = Rnd(6)
		If success > failed Then 
			Print "Dragon Claws does "+monsterpower +" points of damage."
			player\health=player\health-monsterpower
		Else
			Print "The Dragon tried to bite, but, has no teeth."	
		EndIf
	EndIf 
Else
	Print "The Dragon is too tired to attack."	
EndIf

FlushKeys()
Print
Print player\name+":"+player\health+" vs Dragon:"+monster\health
Until monster\health<0 Or player\health<0 

If monster\health < 0 
	Print "You slayed the Bad Breath Dragon."
	Else
	Print "The Dragon is having smoked Hero for dinner."		
End If 

If player\health < 0
	Print "You are Toast."
Else
	Print "You live up to your name Great Knight."	
End If
WaitKey()

Comments

Yo! Wazzup?2007
Wow I kept thinking I'll lose but I won lol with 10hp left


Yo! Wazzup?2007
THANKS man this code is really helpful I'm really learning from this :)
One of 2 code archive entries that I can actually understand


Yo! Wazzup?2007
Hahaha kill it with a piano by instead of typing 1 or 2 type 1749553984 MUAHAHAHAHA!!!




Techlord2007
LOL. A Piano!

Try this Adlib-able Version with Fairy Healing.



Yo! Wazzup?2007
LOL my Super Wound is a piano :)
"Your drop a piano Super Move inflitcts a Critical Wound for 40 points of damage."


Techlord2007
LOL. "Your Big Mac Attack Super Move inflicts a Critical Wound For 49 points of damage."


Code Archives Forum