Need Game Examples and HELP

Monkey Forums/Monkey Beginners/Need Game Examples and HELP

Rell(Posted 2015) [#1]
1. How to put up a score and a counter system ex.score 1000 and counter go up by 1
2.How to make a tic-tac-toe example
3.How to make a health bar and a xp bar
4. How to make different rooms for characters ex. room 1, room2, room3, etc and title screen
Thanks again


Duke87(Posted 2015) [#2]
Maybe this helps you to find a starting Point.



Bye Duke


Duke87(Posted 2015) [#3]
Give me a Second, i try to programm a Tic Tac Toe as simple as can be. I just need to extract some of my Framework Code to create a stand-alone App for you.


Duke87(Posted 2015) [#4]
So, here's a little TicTacToe Game.
There is a little failure on checking for winner. Don't know why. But i have no time to check it now.

Actually i would programm the game a little bit different, but this would be more confusing. (just was hacking the code).

But it may help you answering some of your Questions :D




Rell(Posted 2015) [#5]
Thanks for the help


Rell(Posted 2015) [#6]
Can someone help me with this can't seem to figure it out (syntax error expecting member declaration) I follow it from the learn monkey pdf what does it mean

Import mojo

Function Main()
New Game
End
Class Game Extends App
Field player:Image
Field x:Float
Field y:Float
Method OnCreate()
player = LoadImage ("boing.png")
SetUpdateRate 60

End

Method OnUpdate()

If KeyDown (KEY_LEFT) Then x = x - 4
If KeyDown (KEY_RIGHT) Then x = x + 4
If KeyDown (KEY_UP) Then y = y - 4
If KeyDown (KEY_DOWN) Then y = y + 4

End

Method OnRender()
Cls 64, 94, 128
DrawImage player, x, y

End


dawlane(Posted 2015) [#7]
You are missing End for the class declaration.
Instead of just using End use
End Method
End Class
EndIf
And use the keyword Strict at the beginning of the file. This means that you have to declare function/method types as well as return types.
Strict
Import mojo

Function Main:Int()
	New Game
	Return 0
End

Class Game Extends App
	Field player:Image
	Field x:Float
	Field y:Float
	Method OnCreate:Int()
		player = LoadImage ("boing.png")
		SetUpdateRate 60
		Return 0
	End Method

	Method OnUpdate:Int()
		If KeyDown (KEY_LEFT) Then x = x - 4
		If KeyDown (KEY_RIGHT) Then x = x + 4
		If KeyDown (KEY_UP) Then y = y - 4
		If KeyDown (KEY_DOWN) Then y = y + 4
		Return 0
	End Method

	Method OnRender:Int()
		Cls 64, 94, 128
		DrawImage player, x, y
		Return 0
	End Method
End Class



Rell(Posted 2015) [#8]
Thanks guy


Duke87(Posted 2015) [#9]
by the way, if you show your code, please use [ codebox] ... [/ codebox]. makes the sources better readable :).

edit:
a little hint:

if you Load your images like:
img = LoadImage ( "myimage.png",1,Image.MidHandle)

you set the handle to your image to the middle coordinates.

if you then use your images like:
DrawImage img,X,Y,_angle, scaleX,scaleY
you can easily rotate and scale them.

the scales i compute like the following:
scaleX = (sizeInPxl / img.Width() )

sizeInPxl means, you can scale them to the Pixelsize you want.
So you can load images with like 256x256 Pxl, but you just want have them like 128x128 Pxl scaled on Screen, write something like:

DrawImage img,X,Y,0,128.0/img.Width(),128.0/img.Height()


Bye Duke


Duke87(Posted 2015) [#10]
Strict
Import mojo

Function Main:Int()
	New Game
	Return 0
End

Class Game Extends App
	Field player:Image
	Field x:Float
	Field y:Float
        Field angle:Float = 0
        field Pxl:float = 64
	Method OnCreate:Int()
		player = LoadImage ("boing.png",1,Image.MidHandle)
		SetUpdateRate 60
		Return 0
	End Method

	Method OnUpdate:Int()
		If KeyDown (KEY_LEFT) Then x = x - 4
		If KeyDown (KEY_RIGHT) Then x = x + 4
		If KeyDown (KEY_UP) Then y = y - 4
		If KeyDown (KEY_DOWN) Then y = y + 4
                If KeyDown (KEY_Q) then angle -= 1
                If KeyDown (KEY_E) then angle +=1
                if KeyDown (KEY_W) then Pxl +=1
                if KeyDown (KEY_S) then Pxl -=1
		Return 0
	End Method

	Method OnRender:Int()
		Cls 64, 94, 128
		DrawImage player, x, y,angle,Pxl / player.Width(),Pxl/player.Height()
		Return 0
	End Method
End Class



Rell(Posted 2015) [#11]
what does syntax error expecting declaration means and how to solve it


Gerry Quinn(Posted 2015) [#12]
In the example above, you left out the End for your class declaration. So when Monkey came to the bottom of your program, as far as it was concerned it was in the middle of you declaring your Game class, and you had just finished declaring the Render() method. So it was expecting you to go on by declaring another method of the Game class.

Of course ending the class works too, and that was what you meant to do. But computers are not very good at understanding all possible contexts of an error message. Generally when you get an error you should look around for something wrong nearby, but the problem is not always the most obvious thing from what the error says.

You should use tab indents to help keep your starts and ends balanced, as that's a very easy mistake to make (this applies to just about any programming language),




Rell(Posted 2015) [#13]
thanks alot Gerry