juego en proceso

Previous topic - Next topic

Jonás Perusquía

Hola mis queridos amigos, estoy haciendo un juego que empezó solamente como una prueba de código....

Lo que quiero hacer es que controles un pequeño sprite "medal.png" con el mouse y cuando toque cualquiera de los cuadritos verdes callendo "DRAWREC" salga Game Over

Ustedes saben que GLBasic se maneja por coordenadas...

El problema que tengo es que no puedo lograr que cuando un rectangulo verde toque al sprite, salga GameOVer...

Lo que he logrado es que cuando la posición del mouse sea igual a cualquier parte de rectangulo, aparezca GameOver

no se si me estoy explicando bien, pero el problema es que la mitad del sprite puede estar dentro de un rectangulo verde, pero no saldrá GameOver si la posición del mouse no está dentro del rectangulo... ese es el problema

éste es el código de mi juego:
Code (glbasic) Select
SETCURRENTDIR("Media") // go to media files
LOADFONT "smalfont.png", 0
LOADSPRITE "medal.png", 0
GLOBAL sx,sy,mx,my,b1,b2,y,x,x2,y2,x3,y3,rx,ry
GETSCREENSIZE sx,sy
SETFONT 0
LIMITFPS 60
PLAYMUSIC "ditrabox2.mp3", TRUE
//--- VARIABLES ---//
y=-20
x=RND((sx-15)+5)
x2=RND((sx-15)+5)
y2=-20
x3=RND((sx-15)+5)
y3=-20
rx=30
ry=60
GOSUB menu


//--- MENU ---//
SUB menu:
CLEARSCREEN RGB(0,0,0)
PRINT "Start Game", sx/2-30,sy/2
SHOWSCREEN
MOUSEWAIT
GOSUB game
ENDSUB


//--- OBJETOS Y MOVIMIENTO ---//
SUB game:
WHILE y < sy+30

MOUSESTATE mx,my,b1,b2

DRAWSPRITE 0, mx,my

//--- RECTANGULOS VERDES ---//
DRAWRECT x,y, rx, ry, RGB (100,244,100)
DRAWRECT x2,y2, rx, ry, RGB (100,244,100)
DRAWRECT x3,y3, rx, ry, RGB (100,244,100)

y=y+3
y2=y2+4
y3=y3+5

SHOWSCREEN

CLEARSCREEN
//--- OPCIONES CUADRO 1---//
IF y >= sy+30
y=-20
ENDIF

//--- OPCION 1 FIN ---//
IF mx >= x AND mx <= x+30
IF my >= y AND my <= y+60
CLEARSCREEN RGB(149,0,0)
PRINT "GAME OVER", sx/2-30,sy/2
SHOWSCREEN
MOUSEWAIT
GOSUB menu
ENDIF
ENDIF

//--- NUEVA POSICIÓN ---//
IF y=-20
x=RND((sx-15)+5)
ENDIF

//--- OPCIONES CUADRO 2---//
IF y2 >= sy+30
y2=-20
ENDIF

//--- OPCION 2 FIN ---//
IF mx >= x2 AND mx <= x2+30
IF my >= y2 AND my <= y2+60
CLEARSCREEN RGB(149,0,0)
PRINT "GAME OVER", sx/2-30,sy/2
SHOWSCREEN
MOUSEWAIT
GOSUB menu
ENDIF
ENDIF

//--- NUEVA POSICIÓN ---//
IF y2=-20
x2=RND((sx-15)+5)
ENDIF

//--- OPCIONES CUADRO 3---//
IF y3 >= sy+30
y3=-20
ENDIF

//--- OPCION 3 FIN ---//
IF mx >= x3 AND mx <= x3+30
IF my >= y3 AND my <= y3+60
CLEARSCREEN RGB(149,0,0)
PRINT "GAME OVER", sx/2-30,sy/2
SHOWSCREEN
MOUSEWAIT
GOSUB menu
ENDIF
ENDIF

//--- NUEVA POSICIÓN ---//
IF y3=-20
x3=RND((sx-15)+5)
ENDIF
WEND
ENDSUB
<HTML><BASIC><EC>
Be free and do good things

mentalthink

Hola Jonaspm, mira te dejo un pequeño programa que te he hecho, ya que la manera en la que has puesto el código, me lia un poco la cabeza, no suelo usar ni SUBS ni Gotos...

Por otro lado, si necesitas saber como funciona mejor GLbasic, MRTAtoad tiene unos libros excelentes, y són lo unicos en el Mercado, están en Inglés, pero son sencillos de entender, su precio es muy económico en su version digital, unos 6 o 7 €, lo puedes encontrar en LULU Books, pero seleccionando la lenua Inglesa...

Un saludo JonasPM, y si no entiendes mucho el código dimélos...


[attachment deleted by admin]

Jonás Perusquía

#2
mentalthink, gracias por el programa, despues de escribir el post, busqué en el Manual, y encontré el comando

SPRCOLL()


ese comando ha solucionado mi problema, te agradezco tu aportación, y si, la verdad estoy algo atorado con GLBasic, pero por el momento solo haciendo pequeñas pruebas... gracias!!!
<HTML><BASIC><EC>
Be free and do good things

Jonás Perusquía

he terminado la versión BETA de mi juego/prueba, aqui la descarga:



[attachment deleted by admin]
<HTML><BASIC><EC>
Be free and do good things

erico

What a great beta game!
Don´t forget you can also calculate collisions by coordenates, it may be more work, but it could be more compatible/fast through different platforms?

Anyway, great stuff. Movement is smooth.
Only quibble is that the ship is a little rough compared to the meteors. :-[

Jonás Perusquía

thanks! :)

i plan to add:

-Life counter
-Time counter
-Exit button
<HTML><BASIC><EC>
Be free and do good things

erico

Your code is quite unusual (and unique), now that I read mentalthink´s post...
But that, in my opinion, is exactly what basic is all about, to achieve first and fast results.

My own codes are really absurd, but they get there too :).
Sometimes, checking snipets from the more experienced coders on the forum, I learn a lot, other times, I don´t understand anything at all! Most of the times the later :D

Mr.Tatoads books are great, check them out. I have a couple here, got the electronic versions.

Let us know how your advancement goes, the proposed plan is great!

mentalthink

Pues JonasPm, con el tiempo que llevas, has hecho más que yo en 2 meses cuando empezé... como comentá Erico, "empapaté" bien con todo lo que hay en el foro, vas a disfrutar una barbaridad....

Como dice Hark0, sigué dándole caña y dentro de un año, ya verás...

@Erico, you not are the only one, sometimes I read some Master´s Code, and I don´t understood nothing... I rebember the DrPetters port, for make sounds in real time... not it´s becuase It´s bad wrote, but GLbasic it´s too powrfull and sometimes are very complex, if one not it´s a professional programmer...

Jonás Perusquía

gracias por su apoyo :D}
de hecho, estoy encantado con GLBasic, tiene mucho poder!

ya he publicado la versión 1.7 del juego "DitraFall" para PC y Android

la versión de PC funciona con las teclas, la version para Android funciona con el touch(algo obvio jeje)

ya he abierto la página del "pequeño estudio" y ahi publicaré los juegos

desafortunadamente no cuento con el dinero necesario para subir el juego a Google Play asi que ni modo :/

<HTML><BASIC><EC>
Be free and do good things

hardyx

Cuando he visto el primer post te iba a hablar sobre SPRCOLL(), pero ya veo que has avanzado rápido y lo has descubierto por tu cuenta. Suerte con esos juegos.

Jonás Perusquía

Ya he avanzado el juego bastante!

ahora el problema que tengo es que tengo muchos ROTOSPRITE y alenta el juego bastante (en Android) y la aplicación está dirigida principalmente a Android...


no saben si en la siguiente versión de GLBasic irá mas rápido?
<HTML><BASIC><EC>
Be free and do good things

mentalthink

Hay una manera que comentán siempre que es más rápida que lo Sprites, que es usar Polyvectors...

Otra manera que se me ocurre, es que en vez de hacer un rotosprite , hagas una secuencia de imagenes, tampoco sin pasarte , y tendrás más o menos bien rotados los objetos... pero la gente por aqui y por alla, siempre dicen que los polyvector son más rapidos... eso si tendrás que aplicar las mates para hacerlos rotar...

Hark0

También está la opción manual.

Coges el sprite y lo rotas X veces. De cada giro sacas una imagen. Luego las pegas en una imagen grande una al lado de otra. Y lo cargas con loadanim. Lo pintas con drawanim codigo de la imagen, fotograma, x, y...

;)
http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

Jonás Perusquía

gracias por sus respuestas, ya he corregido el problema de la lentitud, y era causado porque dentro de un WHILE, tenía un IF, y dentro de ese IF tenía un LOADSPRITE...
<HTML><BASIC><EC>
Be free and do good things

Jonás Perusquía

una pregunta, alguien sabe de algún tutorial o algo sobre hacer animaciones?

me gustaría que la nave espacial del juego tuviera un poco de movimiento :)
<HTML><BASIC><EC>
Be free and do good things