text adventure editor

BlitzMax Forums/BlitzMax Beginners Area/text adventure editor

Joe90(Posted 2011) [#1]
I was just wondering if you thought blitzmax was a good language for creating a text adventure editor to allow you to write your own text based games using blitzmax gui. I know there are a lot of editors out there already (inform, quest, adrift, tab, suds etc) but id like to write a text adventure editor for my own personal use and it would teach me a lot about strings and lengths of strings etc.

Would it be better to write this using visual basic or c++???

Blitzmax i think is good for 2d games but i dont think its good for writing text based games.

Which language would you suggest???

Thankyou


Czar Flavius(Posted 2011) [#2]
Oh dear, this is a question only you can answer.

The two main questions are:
Which language do you have the most skills in?
Which language do you want to learn more?

Any of those languages would be capable of this task.


jsp(Posted 2011) [#3]
What Czar said!

Would it be better to write this using visual basic or c++???

Why? What make you think so?

Blitzmax i think is good for 2d games but i dont think its good for writing text based games.

Again, why? Is there anything missing?


Joe90(Posted 2011) [#4]
well the reason being im sorta looking at delphi and blitz basic as it would be a lot easier to code using windows and menus.

I love blitzmax but the gui for windows is not that good. For instance if i wanted to change the color of text i can just click in the properties window of visual and make the change.

I wanted to make a text adventure editor using the GUI in blitzmax.

Wouldnt it be a lot easier to write a text adventure with a language that had better support for windows.

I dont just want to write a text adventure. I want to make an editor that i can use to make text adventure games. Maybe a drop and drag application where no code is needed to make the puzzles.

Do you think blitzmax is a good program to use for this kind of application?????


Joe90(Posted 2011) [#5]
Id like to use blitzmax to write an editor but im not sure where to start on this project. Its a project for me really so i can get used to strings and such.

Ive searched the forums for text adventure but nothing comes up.

Would you create a text adventure using windows or would you actually use blitzmax to write it.

Is there any blitzmax examples of how this can be done??? I cant find any on the web or in these forums???

Cheers


jsp(Posted 2011) [#6]
I love blitzmax but the gui for windows is not that good.

Hmm, it depends what you need and want. I did all my tools with it and for me it works, others have created editors for their games, even Leadwerks is using it with his 3D Engine. Changing a textcolor is not that magic, but you are right there is no properties you can change to do that, if you need something like that have a look at the GUI Editor I wrote (in my sig, also written in Max)

I want to make an editor that i can use to make text adventure games.

That is quite a big task and when you write: "Its a project for me really so i can get used to strings and such." I am not sure if such a project is not a bit too big at this time.

Do you think blitzmax is a good program to use for this kind of application?????

Could be done with almost all languages.

First I think you should have a good idea, how it should look like and work (just for yourself). Start with a simple construct you can extend further.


Joe90(Posted 2011) [#7]
ok thankyou very much.

I want to design a good parser for a text adventure. Can anyone show me some examples of making a good parser using blitzmax???

Cant find any examples anywhere?????

Cheers


Czar Flavius(Posted 2011) [#8]
If this is to use rather than to learn parsing, I can suggest LibXml. Brucey has a module.


Warpy(Posted 2011) [#9]
No, don't use XML! Not at all suitable for a text adventure.

I've written a fairly robust general parser that might be useful to look at.


Shortwind(Posted 2011) [#10]
Joe90: First off, you don't need a GUI to write a good text adventure editor. Of course it will look dated, but isn't that the point of the text adventure?

Second, any language can be used to write text adventures, of course some being easier than others. (Example, I don't think you'd want to use BrainF*ck unless your very, very obsessed. LOL)

Anyway, below I will post some code for a text, windowing routine that should give you some ideas, and a little understanding on string handling in blitzmax. Hope it helps.

*** Most importantly, have you decided on your data layout? In other words, have you decided on how your going to keep track of your vocabulary, rooms directions/descriptions, how your going to handle objects? These are very important before you ever even begin thinking about creating the actual "editor" for your game. ***

I would strongly suggest you start off with a basic text adventure with a few rooms, objects, and vocabulary. This will give you a better understanding of how blitzmax is going to work for you, and also, allow you to get a better grasp on how your going to handle your data.

With blitzmax being somewhat OOP, converting from the old world of array's and strictly procedural programming, isn't too difficult. So if your used to using blitzmax types you will probably be able to structure the program even easier.

*Have you written a text adventure before? Just curious, if your have, in what language you attempted it, and how you handled your data. :) *

Alas, I will now post some code. No expert coding here, but hopefully you can get some use out of it. :)

Basic Window Routine:
Strict
Graphics 1024,768,0,60

Local mywindow:windowbox=WindowBox.Create()

mywindow.setwindowfont("c:\windows\fonts\consola.ttf",22)
'mywindow.setwindowfont("c:\windows\fonts\arial.ttf",22)
mywindow.setpos(150,100)
mywindow.setsize(30,20)
'mywindow.settexture("text_texture.png")

Cls
SetColor 255,255,255
SetBlend AlphaBlend

mywindow.show()
mywindow.CurX=0
mywindow.CurY=0
mywindow.printwrap("{Y}Hello.~n~n")
Flip
Delay(250)

mywindow.printwrap("{W}This is a {Red}test {W}of something.")
Flip
Delay(500)

mywindow.printwrap("And more testing is in order.")
Flip
Delay(500)

mywindow.printwrap("Because the {Y}National {W}concensis is that I'm more {Red}off {W}than more on.")
Flip
Delay(500)

mywindow.printwrap("Even more {Red}unbelievable {W}is that this thing might be working.~n~n")
Flip
Delay(500)

mywindow.printwrap("Here is more testing to see if the testing is testing the testing that is tested.")
Flip


Repeat
Until KeyDown(KEY_ESCAPE) Or AppTerminate()

Type WindowBox
	'Global WindowBoxList:TList = New TList
	Global WinCodes:Codes=New Codes.Create()
		
	Field Font_Name:String
	Field Font_Size:Int
	Field FontMaxWidth:Int
	Field FontMaxHeight:Int
	Field ScreenWidth:Int
	Field ScreenHeight:Int
	Field WindowXPos:Int
	Field WindowYPos:Int
	Field WindowWidth:Int
	Field WindowHeight:Int
	Field TexturePath:String
	Field TextureImage:TImage = New TImage
	Field CurX:Int
	Field CurY:Int
	Field TextLines:TextLine[100]
	Field CurTextLine:Int
	Field CurTopLine:Int
	Field CurRed:Int
	Field CurGreen:Int
	Field CurBlue:Int
	
	Function Create:WindowBox()
		Local w:WindowBox = New WindowBox
		w.SetWindowFont(Null,8)
		w.ScreenWidth=GraphicsWidth()
		w.ScreenHeight=GraphicsHeight()
		w.SetPos(100,100)
		w.SetSize(10,10)
		w.CurX=0
		w.CurY=0
		w.CurRed=255
		w.CurGreen=255
		w.CurBlue=255
		w.CurTextLine=0
		w.CurTopLine=0
		w.TextLines[0]=New TextLine.Create()
'		WindowBoxList.addlast(w:WindowBox)
		Return w:WindowBox
	End Function

	Method SetWindowFont(Font_Namex:String,Font_Sizex:Int)
		Local font:timagefont=LoadImageFont(font_namex,font_sizex,SMOOTHFONT)
		SetImageFont(font)
		Font_Name=Font_Namex
		Font_Size=Font_Sizex
		FontMaxWidth=TextWidth("z")
		FontMaxHeight=TextHeight("z")
		Rem
		FontMaxWidth=TextWidth(Chr(0))
		FontMaxHeight=TextHeight(Chr(0))
		For Local i:Int=65 To 91
			If TextWidth(Chr(i))>FontMaxWidth Then FontMaxWidth=TextWidth(Chr(i))
			If TextHeight(Chr(i))>FontMaxHeight Then FontMaxHeight=TextWidth(Chr(i))
		Next
		End Rem
	End Method
	
	Method SetPos(xpos:Int, ypos:Int)
		WindowXPos=xpos
		windowYPos=ypos
	End Method
	
	Method SetSize(xsize:Int, ysize:Int)
		WindowWidth=xsize
		WindowHeight=ysize
	End Method
	
	Method DrawBorder()
		SetColor 255,255,255
		Local x:Int=WindowXPos
		Local x1:Int=WindowXPos+(WindowWidth*FontMaxWidth)+FontMaxWidth
		Local y:Int=WindowYPos
		Local y1:Int=WindowYPos+(WindowHeight*FontMaxHeight)
		
		DrawLine(x-5,y-5,x1+5,y-5)
		DrawLine(x-5,y-5,x-5,y1+5)
		DrawLine(x1+5,y-5,x1+5,y1+5)
		DrawLine(x-5,y1+5,x1+5,y1+5)
	End Method
			
	Method Show()
		Local x1:Int=(WindowWidth*(FontMaxWidth))
		Local y1:Int=(WindowHeight*(FontMaxHeight))
		DrawBorder()
		'DrawImageRect(TextureImage,WindowXPos,WindowYPos,x1,y1)
	End Method
	
	Method SetTexture(TexturePathx:String)
		TextureImage = LoadImage(TexturePathx)
	End Method

	Method SetDefaultColor(Redx:Int,Greenx:Int,Bluex:Int)
		CurRed=Redx
		CurGreen=Greenx
		CurBlue=Bluex
	End Method
	
	Method PrintWrap(Text:String)
		Local words:String[]
		Local Ret:String[]
		Local soffx:Int=WindowXPos
		Local soffy:Int=WindowYPos
		Local codex:String
		Local wordx:String
		Local kcodevalue:Int
		
		words=Text.split(Chr(32))
		
		For Local t:String=EachIn words
			Ret=t.split(Chr(10))
			t=Left(t,Len(t)-(Len(ret)-1))
			If Left(t,1)="{" Then
				Local y:String[]
				y=t.split("{")
				For Local j:String=EachIn y
					Local tt:Int=Instr(j,"}")
					codex=Left(j,tt-1)
					wordx=Mid(j,tt+1)
					kcodevalue=WinCodes.GetCode(codex)
				Next
			Else
				wordx=t
				codex="None"
				kcodevalue=0
			EndIf
			If wordx.length<WindowWidth-CurX Then
				If CurX=0 Then CurY=CurY+1
					TextLines[CurTextLine].AddWord(wordx,wordx.length,codex,kcodevalue)
				Else
					CurX=0
					CurY=CurY+1
					If CurY > WindowHeight Then
						CurTopLine=CurTopLine+1
					EndIf
					CurTextLine=CurTextLine+1
					TextLines[CurTextLine]=New TextLine.Create()
					TextLines[CurTextLine].AddWord(wordx,wordx.length,codex,kcodevalue)
				End If
				CurX=CurX+wordx.length+1
			
				If CurX > WindowWidth Then
					CurX=0
					CurY=CurY+1
					If CurY > WindowHeight Then
						CurTopLine=CurTopLine+1
					EndIf
					CurTextLine=CurTextLine+1
				EndIf			
			
				If Len(Ret)>1 Then
					For Local i:Int=1 To Len(ret)-1
						CurX=0
						CurY=CurY+1
						If CurY > WindowHeight Then
							CurTopLine=CurTopLine+1
						EndIf
						CurTextLine=CurTextLine+1
						TextLines[CurTextLine]=New TextLine.Create()
						TextLines[CurTextLine].AddWord("~n",-1,"~n",10)
					Next
				EndIf
		Next
		
		SetColor 0,0,0
		DrawRect(WindowXPos,WindowYPos,WindowWidth*FontMaxWidth,(WindowHeight)*FontMaxHeight)
		SetColor CurRed,CurGreen,CurBlue
		Local i:Int=CurTopLine
		Local xpos:Int
		Local ypos:Int
		While (TextLines[i]<>Null) And (i<=(WindowHeight+CurTopLine-1))
			xpos=0
			ypos=(i-CurTopLine)*FontMaxHeight
			For Local j:Words=EachIn TextLines[i].WordList
				If j.thecodevalue<>0 Then
					WinCodes.codefunc[j.thecodevalue]
				EndIf
				DrawText(j.theword,soffx+xpos,soffy+ypos)
				xpos=xpos+((j.thelength+1)*FontMaxWidth)

			Next
		i=i+1
		Wend
	End Method
	 
End Type

Type Words
	Field theword:String
	Field thecode:String
	Field thecodevalue:Int
	Field thelength:Int
	
	Function Create:Words(thewordx:String,thelengthx:Int,thecodex:String,thecodevaluex:Int)
		Local w:Words=New Words
		w.theword=thewordx
		w.thelength=thelengthx
		w.thecode=thecodex
		w.thecodevalue=thecodevaluex
		Return w
	End Function
End Type

Type TextLine
	Field wordlist:TList=CreateList()

	Function Create:TextLine()
		Local w:Textline=New Textline
		Return w
	End Function
	
	Method AddWord(w:String,l:Int,c:String,v:Int)
			ListAddLast(wordlist,words.Create(w,l,c,v))
	End Method

End Type

Type Codes
	Field codefunc()[]
	
	Function Create:Codes()
		Local w:codes=New codes
		w.codefunc=w.codefunc[..255]
		w.codefunc[0]=w.f0
		w.codefunc[1]=w.f1
		w.codefunc[2]=w.f2
		w.codefunc[3]=w.f3
		w.codefunc[4]=w.f4
		w.codefunc[10]=w.f10
		w.codefunc[32]=w.f32
		Return w:Codes
	End Function
	
	Function f0()
		'Print "None"
	End Function
	
	Function f1()
		'Black
		SetColor 0,0,0
	End Function
	
	Function f2()
		'White
		SetColor 255,255,255
	End Function
	
	Function f3()
		'Yellow
		SetColor 255,255,0
	End Function
	
	Function f4()
		'Red
		SetColor 255,0,0
	End Function
	
	Function f10()
		'Print "chr(10)"
	End Function
	
	Function f32()
		'Print "Space"
	End Function
	
	Method GetCode:Int(x:String)
		Select x
		Case "B"; Return 1
		Case "W"; Return 2
		Case "Y"; Return 3
		Case "Red"; Return 4
		Case "~n"; Return 10
		End Select	
	End Method
End Type



Who was John Galt?(Posted 2011) [#11]
In my opinion, Max is an excellent language with the features required to build something like this with minimum headache.

Joe90: First off, you don't need a GUI to write a good text adventure editor. Of course it will look dated, but isn't that the point of the text adventure?
Bang on that man... text adventures are all about immersion, and that means full screen and custom GUI. It does not need to be an all-singing GUI system.