Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[GAME!] ASCII Arkanoid v1.1 (Bug free!)


  • Please log in to reply
4 replies to this topic
TH
  • Members
  • 76 posts
  • Last active: Jan 15 2012 06:22 PM
  • Joined: 28 Oct 2010
Use: LEFT and RIGHT to control the pad

d := 1
u := 0
l := 0
r := 1
h := 0
z := 0
row := 4
col := 1
level := 1
speed := 250-(level*50)
;~ MsgBox % speed
#NoEnv
SetBatchLines -1
xpos := 0
board:=
(
"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU|
xUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUx|
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU|
Oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
TTTTTTxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|"
)
lives := 3
Pts := 0

StringSplit, gm, board, `n
loop %gm0%
{
cct .= gm%a_index% . "`n"
}

col_total := strlen(gm7)
col_total--
row_total := (gm0-1)

Gui, Font, S16 CBlack Bold, Courier New

Gui, Add, Edit, w520 h550 vgame Readonly,
Gui, Add, Edit, w520 h70 vscore Readonly,
; Generated using SmartGUI Creator 4.0
Gui, Show, autosize, Lame ASCII Arkanoid 1.1
gosub updateit



;~ #Persistent
SetTimer, ball, %speed%
return


ball:
IfEqual, row, %row_total% 
{
StringMid, pad_x, gm%gm0%, %col%, 1
pad := "T"
Ifequal, pad_x, %pad%
ph := 1
SoundBeep, 2000, 5
Ifnotequal, pad_x, %pad%
ph := 0
}


IfEqual, row, 4
{
IfEqual, d, 0
{
StringMid, test_u_hit, gm3, %col%, 1
u_pos := "U"
Ifequal, test_u_hit, %u_pos%
{
	gm3 := RegExReplace(gm3, "U","x",cou, 1, col)
	pts+=100
	SoundBeep, 1000, 10
}
Ifequal, test_u_hit, x
{
			StringMid, test_u_hit, gm2, %col%, 1
			Ifequal, test_u_hit, %u_pos%
			{
			gm2 := RegExReplace(gm2, "U","x",cou, 1, col)
			pts+=200
			SoundBeep, 1000, 10
			}	
			Ifequal, test_u_hit, x
			{
				gm1 := RegExReplace(gm1, "U","x",cou, 1, col)
				pts+=300
				SoundBeep, 1000, 10
			}

	
	
}
}
}





IfEqual, row, %row_total% 
{
d := 0
Ifequal, ph, 0
{
Lives--
SoundBeep, 200
gm%row% := RegExReplace(gm%row%, "O","x",cou, 1, col)
row := 4
}
}

IfEqual, row, %row_total% 
{
IfEqual, spin, l
	{
		col++
		spin := "n"
		r := 1
	}
IfEqual, spin, r
	{
		r := 0
		col--
	    spin := "n"
	}
}





IfEqual, row, 4
d := 1


IfEqual, col, %col_total% 
r := 0
IfEqual, col, 1
r := 1





IfEqual, d, 1
{
gm%row% := RegexReplace(gm%row%, "O", "x")
row++
IfEqual, r, 0
{
col--
gm%row% := RegExReplace(gm%row%, "x","O",cou, 1, col)
}

IfEqual, r, 1
{
	col++
gm%row% := RegExReplace(gm%row%, "x","O",cou, 1, col)
}

}





IfEqual, d, 0
{
gm%row% := RegexReplace(gm%row%, "O", "x")
row--

IfEqual, r, 0
{
col--
gm%row% := RegExReplace(gm%row%, "x","O",cou, 1, col)
}

IfEqual, r, 1
{
	col++
gm%row% := RegExReplace(gm%row%, "x","O",cou, 1, col)
}

}



gosub updateit
return





GuiClose:
ExitApp

Left::
loop %level%
{
IfGreater, xpos, 0
{
xpos--
gm%gm0% := RegexReplace(gm%gm0%, "TTTTTT", "xTTTTTTx")


gm%gm0% := RegexReplace(gm%gm0%, "xTTTTTTx", "TTTTTTxx")


gm%gm0% := RegexReplace(gm%gm0%, "xTTTTTTx", "TTTTTT")
spin := "l"
gosub updateit
}
}
Return

Right::
	loop %level%
	{
IfLess, xpos, 31
{
	gm%gm0% := RegexReplace(gm%gm0%, "TTTTTT", "xTTTTTTx")

xpos++

gm%gm0% := RegexReplace(gm%gm0%, "xTTTTTTx", "xxTTTTTT")


gm%gm0% := RegexReplace(gm%gm0%, "xTTTTTTx", "TTTTTT")
spin := "r"
gosub updateit
}
}
Return


updateit:
IfLess, lives, 1
{
	SoundBeep, 300, 50
	SoundBeep, 150, 50
	SoundBeep, 2000, 50
	SoundBeep, 50, 50
	MsgBox,, You've Lost! =0, You Scored %pts% Points
	ExitApp
	Exit
}
  ; Does not affect the timer inside #persistent
cct :=
loop %gm0%
{
cct .= gm%a_index% . "`n"
}
cct := RegexReplace(cct, "x", " ")
GuiControl,,game, %cct%
lvl := (pts-z)
;~ MsgBox % lvl
IfGreaterOrEqual, lvl, 1000
{
	speed := 250-(level*50)
	level++   ; Crazy! After 2000 points =S
	SetTimer, ball, Off
	SetTimer, ball, %speed%
	z := lvl*(level-2)
}
Score :=  "  Score: " . pts . "  TTTTTT x" . lives . "`n  Level: " . Level ; "  Debug: " . lvl

GuiControl,,score, %score%
cct := RegexReplace(cct, "\s", "x")

Return


MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
1) Of course it doesn't affect the speed. You have to use SetTimer again.
2) Use ListVars (and possibly Pause) to check the value of your variables.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio Fran├ža -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
Nice idea! It has more potential.

TH
  • Members
  • 76 posts
  • Last active: Jan 15 2012 06:22 PM
  • Joined: 28 Oct 2010
I,ve updated the script with masterfocus corrections :D

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
The font is too large here. I can only see half of the screen, it shows a scrollbar for the rest of the area.
(Windows 7 32 bit)

After quickly setting it to 12, I could see the "screen", but I noticed some invalid hit detection (after a few hits only the upper row was being hit...linewrap happening? Haven't read the code), and it became unplayable at level 6 or 7 (way too fast compared to previous level), and I saw 2 game over dialog boxes.