Angel Font

Monkey Forums/Monkey Beginners/Angel Font

ewancordiner(Posted 2017) [#1]
Hi, can't seem to get angel font to work within my code as I don't really understand it and the example code doesn't give me much assistance. Does anybody have any tips or example code in which it is running within a program not solely dedicated to it? Thankyou :)


Xaron(Posted 2017) [#2]
I don't know angel font but I can recommend fontmachine from ziggy: http://www.jungleide.com/?page_id=5179


Gerry Quinn(Posted 2017) [#3]
I've used it all the time, albeit a wrapped version. It works fine in my experience - just:

font = New AngelFont "fontname" )
font.DrawText( "Hello", 10, 10 )

is all you need


ewancordiner(Posted 2017) [#4]
Wow I didn't realise it was so simple, all the example code and other peoples appear so complex haha, and how does fontmachine work then Xaron?


ewancordiner(Posted 2017) [#5]
Tried using that and I'm receiving a 'syntax error - expecting class member declaration'. If I shift the code around I am left with "expression cannot be used as a statement"


Xaron(Posted 2017) [#6]
Well without code it's hard to help you. ;)

BTW, font machine code looks similar like:

font = New BitmapFont( "fontname" )
font.DrawText( "Hello", 10, 10 )


ewancordiner(Posted 2017) [#7]
'Importing mojo
Import mojo
Import math

'GameStates

Const STATE_MENU:Int = 0
Const STATE_GAME:Int = 1
Const STATE_UPGRADES:Int = 2
Const STATE_SHOP:Int = 3
Class ClickingGame Extends App

'Defining variables
	'Product Image Library
	Field shoe:Image
	Field bike:Image
	Field rollerblades:Image
	

	'Shop Image Library
	Field america:Image
	'Product Placement
	Field productX:Float = 325.0
	Field productY:Float = 250.0
	
	'Menu Backgrounds
	Field menu:Image
	Field menuX:Float
	Field menuY:Float
	
	'Shop Item bought
	Field rollerbladeupgrade:Int = 0
	'Maths Variables (Upgrades and Shops etc).
	Field upgradecost:Int = 100
	Field auto:Int = 2
	Field total:Int
	Field mouseclicks:Int = 0
	Field clicktotal:Int = 1
	Field ding:Sound
	Field gameState:Int = STATE_MENU

	Method OnCreate()
		'Loading Gamestate
		gameState = STATE_MENU
		SetUpdateRate(60)
		'Loading Images
		shoe = LoadImage("shoe.png", 1, Image.MidHandle)
		ding = LoadSound("ding.wav")
		bike = LoadImage("Bicycle.gif", 1, Image.MidHandle)
		menu = LoadImage("menu.jpg", 1, Image.MidHandle)
		america = LoadImage("American Flag.png", 1, Image.MidHandle)
		rollerblades = LoadImage("rollerblades.gif", 1, Image.MidHandle)

	End
	
	
	
	
	
	
	
	
	
	
	
	
	
	Method OnUpdate()
		Select gameState
			Case STATE_MENU
			'Registering menu hotkeys'
				If KeyHit(KEY_ENTER)
					gameState = STATE_GAME
				End
			
			
			
			
			
			
			
			Case STATE_GAME
				'Implementing base upgrade system
				If mouseclicks >= upgradecost
					If KeyHit(KEY_SPACE)
						mouseclicks = mouseclicks - upgradecost
						upgradecost = upgradecost * 2.5
						clicktotal = clicktotal*2 
					Endif
				Endif				
			
				If KeyHit(KEY_ESCAPE)
					gameState = STATE_MENU
				Else If KeyHit(KEY_U)
					gameState = STATE_UPGRADES
				Else If KeyHit(KEY_S)
					gameState = STATE_SHOP
				Else If MouseHit(MOUSE_LEFT)
					mouseclicks = mouseclicks + clicktotal
					PlaySound(ding,0, 0)
				Endif
			
			
			
			
			
			
			
			Case STATE_UPGRADES
				If KeyHit(KEY_ESCAPE)
					gameState = STATE_GAME
				Elseif KeyHit(KEY_S)
					gameState = STATE_SHOP
				Endif
				
			
			
			
			
			
			
			Case STATE_SHOP
				If KeyHit(KEY_ESCAPE)
				gameState = STATE_GAME
				Elseif KeyHit(KEY_U)
				gameState = STATE_UPGRADES
				Endif
			
		End	
	
	End	
	
	Method OnRender()
		Cls(0, 0, 0)
		
		
		Select gameState
		'Inserting graphics within game states
			
			
			Case STATE_MENU
				DrawText("Dominate the Market!", 320, 100, 0.5)
				DrawText("Press Enter to Play!", 320, 400, 0.5)
				DrawText("(0.2)", 590, 460)
				
				
			
			
			
			
			Case STATE_GAME
				Cls(100, 100, 100)
				DrawText("$" +mouseclicks, 300, 125, 0.5, 0.5)
				DrawText("$ Per Click: $" +clicktotal, 300, 375, 0.5, 0.5)
				DrawImage(shoe, productX, productY, 0.5)
				If mouseclicks >= upgradecost
					DrawText("Spacebar to upgrade!", 300, 425, 0.5)
				End
				DrawText("Cost to upgrade:$"+ upgradecost, 300, 400, 0.5, 0.5)
			
			
			
			
			
			
			Case STATE_UPGRADES
				
				Cls(100, 200, 200)
				DrawText("Upgrades", 300, 50, 0.5)


				
			
			
			
			
			
			Case STATE_SHOP
				Cls(200, 200, 200)
				
				
		End
	End
End

Function Main:Int()	

	New ClickingGame()
End



Xaron(Posted 2017) [#8]
Compiles and runs with no problems on my side...


ewancordiner(Posted 2017) [#9]
This code is fine as it is, however I can't seem to write the code so that one of the new font module works.


Xaron(Posted 2017) [#10]
http://www.leidel.net/dl/temp/clickinggame.zip

Basically I just replaced all "DrawText" with "font.DrawText".


ewancordiner(Posted 2017) [#11]
Thankyou that's really helpful, I couldn't for the life of me work out how to do it haha.


ewancordiner(Posted 2017) [#12]
Hi Xaron, just tried copying the new text you implemented into my monkey program and I'm left with type illegal expression. i also tried copying and pasting your modified code into a new monkey program and booting from there and I'm met with errors that angelfont have modpath errors and that 'font' is not a correct type etc.


Gerry Quinn(Posted 2017) [#13]
You've copied and pasted something into something else, and made a combination that doesn't compile. Probably for lots of reasons, which means that the errors you get don't really mean anything except that nothing is working. This is not a Monkey thing, every programming language is like this.

"Hi Xaron, just tried copying the new text you implemented into my monkey program "

Don't do that. Fix your program, one line at a time. Start with something that works, and modify it. Then, errors you get will be meaningful.


ewancordiner(Posted 2017) [#14]
Okay