Worn and Weary

BlitzPlus Forums/BlitzPlus Beginners Area/Worn and Weary

Hi everyone,

I've been at this code all night and I can't find out why it isn't working. I'm trying to make a simple game with BlitzPlay.

In my efforts I've ended up copying almost all of this code from the second post of this thread. And it still doesn't work.

If anyone can help I'd much appreciate it. What I want it to do is just display player positions and "Crystalsleft". I don't even want to worry about the crystals yet, because once I figure out my problem it should fall into place quite nicely.

Here's the code, and thanks to all.

AppTitle "Crystal Catcher"
Graphics 640,480,32,2
SeedRnd MilliSecs()

Global x=5,y=5
Global crystalnum,crystalsleft
Global crystaltimer
Global timer=0

game=StartNetGame()

Select game
	Case 0
		RuntimeError("Error, cannot commence!")
		End
	Case 1 
		Print "*** C R Y S T A L   C A T C H E R ***"
		Print "Game Joined!"
	Case 2
		Print "*** C R Y S T A L   C A T C H E R ***"
		crystalnum=Input$("Number of Crystals?")
		crystaltimer=Input$("Speed of Game (Default 300)?")
		;Global players=Input$("Number of Players?")
		Print "Game Started with "+crystalnum+" crystals at "+crystaltimer+" speed!" ;and "+players+" players!"
End Select

Global player=CreateNetPlayer("Brian")

crystalsleft=crystalnum

Type crystal
	Field x,y
End Type

For t=1 To crystalnum
 	c.crystal=New crystal
	c\x=Rnd(10,630):c\y=Rnd(10,470)
Next

While Not KeyHit(1)
	sendget()
	HUD()
	updatecrystals()
	updateplayers()
	Flip
	Cls
Wend 

Function sendget()
	io = MilliSecs() / 50
	If io > ioi Then 
		SendNetMsg 1, y + x * 800, player, 0, 1
		SendNetMsg 2,crystalsleft,player,0,1
	EndIf
	If RecvNetMsg() Then
		msgType	  = NetMsgType()
		msgFrom   = NetMsgFrom()
		msgData   = NetMsgData$()
		If msgType=1
			a# = msgData   / 800
			b# = msgData Mod 800
		EndIf
		If msgType=2
			crystalsleft=Int(msgData)
		EndIf 
	End If
End Function 

Function HUD()
	Color 255,255,255
	Text 0,0,"Crystals: "+crystalnum
	Text 0,20,"Crystals Left: "+crystalsleft
End Function 

Function updatecrystals()
	Color 0,0,255
	For c.crystal=Each crystal
		Rect c\x-10,c\y-10,20,20,1
		If x<=c\x+10 And x>=c\x-10
		If y<=c\y+10 And y>=c\y-10
			Delete c
			crystalsleft=crystalsleft-1
		EndIf
		EndIf 
	Next 
	If timer>=crystaltimer
		c.crystal=First crystal
		For t=1 To crystalsleft
			c\x=Rnd(640):c\y=Rnd(480)
			c.crystal = After c
		Next
		timer=0
	EndIf
	timer=timer+1
End Function

Function updateplayers()
	Color 0,128,0
	Rect x-5,y-5,10,10,1
	If KeyDown(203)
		x=x-10
		If x<=5
			x=5
		EndIf
	EndIf
	If KeyDown(205)
		x=x+10
		If x>=635
			x=635
		EndIf 
	EndIf 
	If KeyDown(200)
		y=y-10
		If y<=5
			y=5
		EndIf 
	EndIf
	If KeyDown(208)
		y=y+10
		If y>=475
			y=475
		EndIf 
	EndIf 
	Color 128,0,0
	Rect a-5,b-5,10,10,1
End Function 


Ok well I discovered the nature of my problem, but not the reason why.

Its getting messed up because of strings and integer confusion. I took the suggestion in the command reference, which is to make a string and parse the info out, and it works better.

The program still doesn't work because its crap, so I've since deleted it and am trying something new.

Now my question is, why does the example from an old post work fine though??