Forza4!

You can post your code snippets here for others to use and learn from
Post Reply
divsalv
Posts: 23
Joined: Sun Mar 22, 2015 3:01 am

Forza4!

Post by divsalv » Wed Apr 20, 2016 11:48 am

Hi, I wrote a simple Forza 4 game, which works well enough, but that is for two players.
I would like to help turn it into a game client / server, could someone help me?

Code: Select all

;Forza 4 Version 0.94 by Di Vincenzo Salvatore
@DISPLAY {Title="Forza4",Color=#BLUE,width=800,height=600}
@BRUSH 10,"freccia.png",{transparency=#RED} @BRUSH 11,"freccia2.png",{transparency=#RED}
SetFormStyle(#ANTIALIAS) SetFillStyle(#FILLCOLOR)
CreateBrush(0,60,60,#BLUE) CreateBrush(1,60,60,#BLUE) CreateBrush(2,60,60,#BLUE)
SelectBrush(0)	Circle(0,0,29,#BLACK)	EndSelect
SelectBrush(1)	Circle(0,0,29,#YELLOW)	EndSelect
SelectBrush(2)	Circle(0,0,29,#RED)   EndSelect
Dim griglia[8][10]
Function init()
	colonna_scelta=0 giocatore=1 piene=0 drighe=0 dcolonne=0 delta=0 conta=0 posizione =0
	For Local i=0 To 7 Step 1 For Local j=0 To 9 Step 1 griglia[i][j]=0 Next Next
EndFunction

Function check_game()
	posizione =-1
	For Local k=7 To 0 Step -1
		If griglia[k][colonna_scelta-1]=0
			posizione = k	
		EndIf
	Next
	If posizione <0
		SystemRequest("Forza4", "La colonna scelta è piena!", "OK", #REQICON_WARNING) Return(0)
	EndIf
	griglia[posizione][colonna_scelta-1]=giocatore	piene=piene+1	
	For Local z=7 To 0 Step -1 ;Ora si verifica che il giocatore abbia fatto 4
		For Local w=0 To 10 Step 1
			For Local s_step=1 To 4 Step 1
				Switch(s_step)
				Case 1: ;Movimento orizontale a destra
					drighe = 0 dcolonne = 1	Break
				Case 2: ;Movimento diagonale a destra in basso
					drighe = -1 dcolonne = 1 Break
				Case 3: ;Movimento verticale in basso
					drighe = -1 dcolonne = 0 Break
				Case 4: ;Movimento Diagonale a sinistra in basso
					drighe = -1 dcolonne = -1 Break
				EndSwitch
				r=z c=w	conta = 0
				For Local delta=0 To 4 Step 1
					If r<0 Or r>=8 Then Break
					If c<0 Or c>=10 Then Break					
					If griglia[r][c]=giocatore 
						conta=conta+1 r = r + drighe c = c + dcolonne
					EndIf
				Next
				If conta=4
					draw_griglia() 
					winner=SystemRequest("Forza4", "Il giocatore "..giocatore.." ha vinto la partita!", "Rigioca|Esci")			
					Switch winner Case 0:	End Case 1: init() draw_griglia() Return(0)  EndSwitch
				EndIf						
			Next			
		Next
	Next
	If piene= 8*10
		draw_griglia()
		stall=SystemRequest("Forza4", "Stallo la griglia è piena!", "Rigioca|Esci")			
		Switch stall
			Case 0:	End	
			Case 1:	init()	draw_griglia()
		EndSwitch		
	EndIf
	If giocatore=1	giocatore = 2  Else  giocatore = 1  EndIf	
EndFunction
Function Draw_Griglia();Funzione che disegna la griglia
	xpos=5	ypos=525
	For Local a=0 To 7 Step 1
		For Local i=0 To 9 Step 1
			DisplayBrush(griglia[a][i],xpos,ypos) xpos=xpos+64
		Next
		xpos=5	ypos=ypos-64
	Next
EndFunction
posx_butt={14,78,142,206,270,334,398,462,526,590}
Function p_EventFunc(msg)
	For Local v=0 To 9 Step 1
		If msg.id=v
		Switch msg.action
		Case "OnMouseOut": DisplayBrush(10, posx_butt[v], 10)   ; normal button
		Case "OnMouseOver": DisplayBrush(11, posx_butt[v], 10)   ; highlight button
		Case "OnMouseDown": DisplayBrush(11, posx_butt[v], 10)   ; highlight button
		Case "OnMouseUp":
			DisplayBrush(10, posx_butt[v], 10)   ; normal button
			colonna_scelta=ToNumber(v+1) check_game() draw_griglia()
		EndSwitch
		EndIf
	Next	
EndFunction
evttable = {OnMouseOver = p_EventFunc, OnMouseOut = p_EventFunc, OnMouseDown = p_EventFunc, OnMouseUp = p_EventFunc}
;Parte di codice che disegna e crea i pulsanti per inserire i gettoni
xpos_freccia=14
For Local s=0 To 9 Step 1
	DisplayBrush(10,xpos_freccia,10)
	MakeButton(s,#SIMPLEBUTTON,xpos_freccia,10,40,46,evttable)
	xpos_freccia=xpos_freccia+64
Next
init() draw_griglia() EscapeQuit(True)
Repeat	WaitEvent() Forever
Missing image file of the arrows, which are easy to make with Paint.

User avatar
Juan Carlos
Posts: 452
Joined: Mon Sep 06, 2010 1:02 pm
Location: Palencia
Contact:

Re: Forza4!

Post by Juan Carlos » Thu Apr 21, 2016 1:44 pm

When the game is available? With sounds, graphics, cover, etc. And for all Amiga systems.

divsalv
Posts: 23
Joined: Sun Mar 22, 2015 3:01 am

Re: Forza4!

Post by divsalv » Fri Apr 22, 2016 3:15 pm

when someone helps me to turn it into a game client / server.
The code works on all systems already.

User avatar
Juan Carlos
Posts: 452
Joined: Mon Sep 06, 2010 1:02 pm
Location: Palencia
Contact:

Re: Forza4!

Post by Juan Carlos » Sat Apr 23, 2016 1:16 pm

Only I can help you with graphics and sounds,

Post Reply