Colisiones simples en VBScript + HTA

Iniciado por JohnConnor, 3 Mayo 2012, 10:06 AM

0 Miembros y 1 Visitante están viendo este tema.

JohnConnor

Hola, este es mi primer post y les quiero mostrar un "intento de juego" que no tiene como objetivo el entretenimiento sino que es un ejemplo de colisiones básicas en vbscript.

Dejo el link de .rar --->  http://www.mediafire.com/?dcje4xhf7z48445

y aca el codigo:

Código (vb) [Seleccionar]

<HTML><HEAD><SCRIPT LANGUAGE="VBScript">
REM -----------------------------------------------------------------------------
REM              ***************POWERED By JohnConnor************
REM              *        Buenos Aires - Argentina. 30/05/2012  *
REM              *       All code is typed in Notepad++         *
REM              ************************************************
REM .............................................................................
REM                   WEB:  WWW.JUEGOMANIA.WEB44.NET
REM .............................................................................
Sub Window_OnLoad()
self.resizeto 400,400 : obstacle.style.left = 100 : obstacle.style.top = 200
TECLAW.value = "0" : TECLAS.value = "0" : TECLAD.value = "0" : TECLAA.value= "0" : TIEMPO_REFRESH = 100 : MOTOR()
MovimientoE()
End Sub
Sub Document_onKeyPress()
if estado.value = "muerto" then
exit sub
end if
If (UCase(Chr(window.event.keyCode)) = "W") Then
TECLAW.value = "1"
end if
If (UCase(Chr(window.event.keyCode)) = "S") Then
TECLAS.value = "1"
end if
If (UCase(Chr(window.event.keyCode)) = "D") Then
TECLAD.value = "1"
end if
If (UCase(Chr(window.event.keyCode)) = "A") Then
TECLAA.value = "1"
end if
End Sub
Sub Document_onKeyUp()
If (UCase(Chr(window.event.keyCode)) = "W") Then
TECLAW.value = "0"
end if
If (UCase(Chr(window.event.keyCode)) = "S") Then
TECLAS.value = "0"
end if
If (UCase(Chr(window.event.keyCode)) = "D") Then
TECLAD.value = "0"
end if
If (UCase(Chr(window.event.keyCode)) = "A") Then
TECLAA.value = "0"
end if
End Sub
Sub MOTOR()
charX = character.style.left : charX = Left (charX, Len(charX)-2)
charY = character.style.top : charY = Left (charY, Len(charY)-2)
charWidth = character.style.width : charWidth = Left (charWidth, Len(charWidth)-2)
charHeight = character.style.height : charHeight = Left (charHeight, Len(charHeight)-2)
obstX = obstacle.style.left : obstX = Left (obstX, Len(obstX)-2)
obstY = obstacle.style.top : obstY = Left (obstY, Len(obstY)-2)
obstWidth = obstacle.style.width
obstWidth = Left (obstWidth, Len(obstWidth)-2)
obstHeight = obstacle.style.height
obstHeight = Left (obstHeight, Len(obstHeight)-2)
if TECLAA.VALUE = "1" then
if coliciones(charX-2, charWidth, charY, charHeight, obstX, obstWidth, obstY, obstHeight) = "" or coliciones(charX-2, charWidth, charY, charHeight, obstX, obstWidth, obstY, obstHeight) = "no" then
for i = 0 to 1
charX = charX - 1
next
end if
end if
if TECLAW.value = "1" then
if coliciones(charX, charWidth, charY-2, charHeight, obstX, obstWidth, obstY, obstHeight) = "" or coliciones(charX, charWidth, charY-2, charHeight, obstX, obstWidth, obstY, obstHeight) = "no" then
for i = 0 to 1
charY = charY - 1
next
end if
end if
if  TECLAD.value = "1" then
if coliciones(charX+2, charWidth, charY, charHeight, obstX, obstWidth, obstY, obstHeight) = "" or coliciones(charX+2, charWidth, charY, charHeight, obstX, obstWidth, obstY, obstHeight) = "no" then
for i = 0 to 1
charX = charX + 1
next
end if
end if
if TECLAS.value = "1" then
if coliciones(charX, charWidth, CInt(charY+2), charHeight, obstX, obstWidth, obstY, obstHeight) = "" or coliciones(charX, charWidth, CInt(charY+2), charHeight, obstX, obstWidth, obstY, obstHeight) = "no" then
for i = 0 to 1
charY = charY + 1
next
end if
end if
character.style.top = CharY
character.style.left = CharX
obstacle.style.top = obstY
obstacle.style.left = obstX
if coliciones(charX, charWidth, CInt(charY+2), charHeight, obstX, obstWidth, obstY, obstHeight) = "si" or coliciones(charX+2, charWidth, charY, charHeight, obstX, obstWidth, obstY, obstHeight) = "si" or coliciones(charX, charWidth, charY-2, charHeight, obstX, obstWidth, obstY, obstHeight) = "si" or coliciones(charX-2, charWidth, charY, charHeight, obstX, obstWidth, obstY, obstHeight) = "si" then
if estado.value = "muerto" then
obstacle.src = "Imagenes/vacio.png"
erdisteMan = window.settimeout("Perdiste()", 900)
else
character.src = "Imagenes/boom.gif"
character.style.width = "200"
character.style.height = "200"
estado.value = "muerto"
sonidos.src = "Sonidos/boom.wav"
erdisteMan = window.settimeout("Perdiste()", 900)
end if
end if
MOTORR = WINDOW.SETTIMEOUT("MOTOR()", TIEMPO_REFRESH)
End Sub
Sub Perdiste()
character.src = "Imagenes/vacio.png"
menu.innerhtml = "Game Over"
sonidos.src = ""
sonidos.delay = "0"
End Sub
Sub MovimientoE()
obstX = obstacle.style.left : obstX = Left (obstX, Len(obstX)-2)
obstY = obstacle.style.top : obstY = Left (obstY, Len(obstY)-2)
if obstX = 0 then
obstX = 500
obstY  = int(rnd * 400)
else
obstX = obstX - 2
end if
obstacle.style.top = obstY
obstacle.style.left = obstX
MOTORD = WINDOW.SETTIMEOUT("MovimientoE()", TIEMPO_REFRESH)
End Sub
Function coliciones(x1, width1, y1, height1,x2, width2, y2, height2)
if  (CInt(x1) + CInt(width1)) > (CInt(x2)) and (CInt(x1)) < (CInt(x2) + CInt(width2)) then
if  (CInt(y1) + CInt(height1)) > (CInt(y2)) and (CInt(y1)) < (CInt(y2) + CInt(height2)) then
coliciones = "si"
else
coliciones = "no"
end if
end if
end function
</Script>
<bgsound id="sonidos" src="Sonidos/fondo.wav" loop="infinite" delay="0">
<TITLE>AlienScript</TITLE>
<HTA:APPLICATION
ID="37832459348"
APPLICATIONNAME="VBScript coliciones"
CONTEXTMENU="NO"
ICON="Imagenes/icono.ico"
SCROLL="NO"
SCROLLFLAT="NO"
SELECTION="NO"
SINGLEINSTANCE="YES"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
VERSION="1.3"
CAPTION="yes"
BORDER="thin"
SysMenu="yes"
INNERBORDER="OFF" />
</head><body topmargin="0" leftmargin="0" rightmargin="0" background="Imagenes/fondo.gif">
<input type="hidden" id="estado" value="vivo">
<input type="hidden" id="TECLAW" value="0"><input type="hidden" id="TECLAS" value="0">
<input type="hidden" id="TECLAD" value="0"><input type="hidden" id="TECLAA" value="0">
<img id="character" style="position:absolute; top:0; left:0; width: 50; height: 50;" src="Imagenes/objUno.png">
<img id="obstacle" style="position:absolute; top: 0; left: 0; width: 30; height: 30;" src="Imagenes/objDos.gif">
<div id="menu" style="position: absolute; top: 160; left: 90; color: lime; font-size: 40; font-family: lucida console; font-effect: emboss;"></div>
</body></html>