Hola! tengo un juego que es de coches, sencillisimo porque estoy empezando y lo que quiero es que cuando llegue a la meta mi choche y gane se reinicie de nuevo y que en el score cuente como una vuelta, luego 2, 3, asi sucesivamente hasta que me maten.
?Como lo hago? Muchas Gracias! :GM8:
Puedes no reiniciar todo el juego, solo una Room, y el score ser?a una variable global por lo que no se reiniciar?a.
O bien (si es necesario reiniciar el juego) una vez que termines la carrera guardes el valor del score en un archivo.ini, reinicies el juego y cargues el valor que acabas de guardar en el archivo. ;)
Cuando llegues a la meta puedes mover tu coche a la posici?n donde empez? la carrera... as? no pierdes variables ni score
cuando terminen las vueltas
pones
[gml]
if score = "vueltas"
score = 0
game_restart()
[/gml]
Muchas Gracias por vuestra ayuda, pero soy novato. Podriais si no es mucho trabajo explicarmelo paso a paso para que pueda hacerlo y asi aprenderlo?
muchas gracias! :GM8:
Imag?nate que el juego consta de 4 vueltas, en el objeto del auto que manejas en evento create v? a la pesta?a score y arrastra el "piece of code" y escribe vueltas=1 luego cuando dicho objeto d? la primera vuelta repite los pasos y escribe vueltas+=1 y por ?ltimo en el evento step vuelve a colocar el "piece of code" y escribe if vueltas=4 {room_restart} algo as? deber?a funcionar.
Ok!! Muchisimas Gracias!! ?Y tu sabes como poner mi Score dentro de la room? le pongo las coordenadas y todo pero no me sale.
Muchas Gracias de Nuevo
n.n Pod?s hacerlo con un "caption" v? a la pesta?a score y juego donde hay un icono con una s, una l y una h... Agrega eso en un evento create y recuerda: S=score(puntos) L=lives(vidas) H=health(salud) entonces deja el de score activo(mejor dicho no teques nada...) Esa es una forma m?s sencilla, y lo dibuja en la ventana. Hay otra que es escribiendolo a la vista: en la pesta?a score v? donde dice draw score y arrastralo en el evento draw de alg?n objeto invisible y que siempre est? en el juego(s? no hay crealo) donde dice caption(creo) le pon?s el nombre que quieras por ejemplo VUELTAS. Y donde dice x escribe: view_xview+32 y donde dice y: view_yview+2 despu?s acomodalo cambiando los n?meros(recuerda x= horizontal entre mayor sea el n?mero m?s a la derecha e y=vertical entre mayor sea m?s abajo) eso es todo.
Pues hice todo lo que me dijiste pero no me sale el Score. No se si estare haciendo algo mal. Lo que hice fue hacer un objeto sin imagen. en el evento Draw le arrastre el Draw Score y rellene como me dijiste (yo puse 400 en x y 16 en y). Luego fui a la room y pinche e la coordenada el objeto invisible pero no me sale.
?Que estoy haciendo mal?
muchisimas gracias.
Necesitamos m?s informaci?n.
Abr? el objeto auto, hac? click en Show Information, copi? todo lo que diga ah? y ponelo ac? as?:
[code*]ac? pon? el texto[/code*]
sacando los asteriscos.
Recuerda agregarle el view_xview y view_yview *esto para que s? dibuje en la view(vista) y te siga. Adem?s el objeto que lo dibuja(el invisible) no es necesario que est? en esas coordenadas, col?calo donde sea. Deber?a funcionar. Edito: si no hac? lo que dice wadk.
Information about object: object0
Sprite: sprite0
Solid: true
Visible: false
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Collision Event with object object1:
start moving in directions 000000000 with speed set to 0
______________________________________________________
Information about object: object1
Sprite: sprite4
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
play sound phantoms; looping: true
set the health to 100
Collision Event with object object4:
bounce not precisely against solid objects
Collision Event with object object5:
bounce not precisely against solid objects
set the health relative to -10
Collision Event with object object6:
jump to the start position
Collision Event with object object7:
jump to the start position
Collision Event with object object8:
jump to the start position
Collision Event with object object9:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object10:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object11:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object12:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object13:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object14:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object17:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object18:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object19:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object20:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object Police:
stop sound coche1
stop sound phantoms
show the video in file video/perder2.wmv 0
restart the game
Collision Event with object meta:
stop sound coche1
stop sound phantoms
show the video in file video/fin.wmv 0
go to room menu with transition effect Blend
Collision Event with object object44:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object45:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object46parado:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object47parado:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Collision Event with object object48parado:
start moving in directions 000000000 with speed set to 0
set the health relative to -5
Keyboard Event for <Left> Key:
start moving in directions 000100000 with speed set to 2.7
set the sprite to sprite3 with subimage 0 and speed 3
Keyboard Event for <Up> Key:
start moving in directions 000000010 with speed set to 2.7
set the sprite to sprite1 with subimage 0 and speed 3
Keyboard Event for <Right> Key:
start moving in directions 000001000 with speed set to 2.7
set the sprite to sprite4 with subimage 0 and speed 3
Keyboard Event for <Down> Key:
start moving in directions 010000000 with speed set to 2.7
set the sprite to sprite2 with subimage 0 and speed 3
Other Event: No More Health:
sleep 1000 milliseconds; redrawing the screen: true
stop sound phantoms
stop sound coche1
show the video in file video/perder1.wmv 0
restart the game
______________________________________________________
Information about object: object3
Sprite: sprite8
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cocherojo with speed 1.3 and at the end stop
Step Event:
execute code:
if direction<45 and direction>-45 //derecha
{
sprite_index=sprite8
}
else
if direction>45 and direction<135 //arriba
{
sprite_index=sprite6
}
else
if direction>135 and direction<225 //izquierda
{
sprite_index=sprite7
}
else
if direction>225 and direction<315 //abajo
{
sprite_index=sprite9
}
______________________________________________________
Information about object: object4
Sprite: sprite13
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochegris with speed 1.7 and at the end stop
play sound coche1; looping: true
Step Event:
execute code:
if direction<45 and direction>-45 //derecha
{
sprite_index=sprite13
}
else
if direction>45 and direction<135 //arriba
{
sprite_index=sprite12
}
else
if direction>135 and direction<225 //izquierda
{
sprite_index=sprite11
}
else
if direction>225 and direction<315 //abajo
{
sprite_index=sprite10
}
Collision Event with object meta:
stop sound coche1
stop sound phantoms
show the video in file video/perder1.wmv 0
restart the game
______________________________________________________
Information about object: object5
Sprite: sprite16
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochetransam with speed 1.45 and at the end stop
Step Event:
execute code:
if direction<45 and direction>-45 //derecha
{
sprite_index=sprite16
}
else
if direction>45 and direction<135 //arriba
{
sprite_index=sprite14
}
else
if direction>135 and direction<225 //izquierda
{
sprite_index=sprite17
}
else
if direction>225 and direction<315 //abajo
{
sprite_index=sprite18
}
Collision Event with object meta:
stop sound coche1
stop sound phantoms
show the video in file video/perder1.wmv 0
restart the game
______________________________________________________
Information about object: object6
Sprite: sprite19
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Camionxoto with speed 2 and at the end continue from start
______________________________________________________
Information about object: object7
Sprite: sprite20
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Camionalba with speed 2 and at the end continue from start
______________________________________________________
Information about object: object8
Sprite: sprite21
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Camionhercules with speed 1 and at the end continue from start
______________________________________________________
Information about object: object9
Sprite: sprite22
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to CocheNormal9 with speed 0.7 and at the end continue from start
______________________________________________________
Information about object: object10
Sprite: sprite22
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal10 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object11
Sprite: sprite22
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal11 with speed 1.5 and at the end continue from start
______________________________________________________
Information about object: object12
Sprite: sprite22
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal12 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object13
Sprite: sprite22
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal13 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object14
Sprite: sprite22
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal14 with speed 0.5 and at the end continue from start
______________________________________________________
Information about object: object17
Sprite: sprite23
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to cochenormal17 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object18
Sprite: sprite24
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal18 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object19
Sprite: sprite23
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal19 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object20
Sprite: sprite24
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal20 with speed 1 and at the end continue from start
______________________________________________________
Information about object: Energia
Sprite: <no sprite>
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Draw Event:
draw the health bar with relative size (0,0,128,16) with back color none and bar color green to red
______________________________________________________
Information about object: buttonjugar1
Sprite: sprite26
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Button:
set the sprite to sprite25 with subimage 0 and speed 3
stop sound Menu
go to room room1 with transition effect Blend
______________________________________________________
Information about object: buttonsalir1
Sprite: sprite28
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Button:
set the sprite to sprite27 with subimage 0 and speed 1
end the game
______________________________________________________
Information about object: buttonhistoria1
Sprite: sprite30
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Pressed:
set the sprite to sprite29 with subimage 0 and speed 1
go to room Historia with transition effect Blend
______________________________________________________
Information about object: buttonobjetivo1
Sprite: sprite32
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Button:
set the sprite to sprite31 with subimage 0 and speed 1
go to room Objetivo with transition effect Blend
______________________________________________________
Information about object: buttoncontroles1
Sprite: sprite34
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Button:
set the sprite to sprite33 with subimage 0 and speed 1
go to room Controles with transition effect Blend
______________________________________________________
Information about object: buttoncreditos1
Sprite: sprite36
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Button:
set the sprite to sprite35 with subimage 0 and speed 1
go to room Creditos with transition effect Blend
______________________________________________________
Information about object: buttonmakina1
Sprite: sprite40
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Button:
stop sound Menu
show the video in file video/lv1.wmv 0
______________________________________________________
Information about object: buttonmenu
Sprite: sprite43
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Mouse Event for Left Button:
set the sprite to sprite42 with subimage 0 and speed 1
go to room menu2 with transition effect Blend
______________________________________________________
Information about object: musicamenu
Sprite: <no sprite>
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
play sound Menu; looping: true
______________________________________________________
Information about object: video
Sprite: <no sprite>
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
stop sound Menu
show the video in file video/lv1.wmv 0
______________________________________________________
Information about object: Police
Sprite: sprite47
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to cochepolicia with speed 1.6 and at the end continue from start
play sound coche1; looping: true
Step Event:
execute code:
if direction<45 and direction>-45 //derecha
{
sprite_index=sprite47
}
else
if direction>45 and direction<135 //arriba
{
sprite_index=sprite44
}
else
if direction>135 and direction<225 //izquierda
{
sprite_index=sprite46
}
else
if direction>225 and direction<315 //abajo
{
sprite_index=sprite45
}
______________________________________________________
Information about object: meta
Sprite: meta
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
______________________________________________________
Information about object: object44
Sprite: sprite50
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to Cochenormal44 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object45
Sprite: sprite50
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set the relative path to cochenormal45 with speed 1 and at the end continue from start
______________________________________________________
Information about object: object46parado
Sprite: sprite24
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
______________________________________________________
Information about object: object47parado
Sprite: sprite23
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
______________________________________________________
Information about object: object48parado
Sprite: sprite22
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
______________________________________________________
?cual es el objeto que dibuja el score?
Ay! perdona, te puse la info del coche.
te pongo la info del score.
Information about object: Score
Sprite: score
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Draw Event:
at position (view_xview+400 ,view_yview+16) draw the value of score with caption Score:
Una preguntita: Cuanto mide la view del room ???? ???
El juego tiene una resolucion de 1280x800 pixeles.
te refieres a eso?
:-[ NO me refiero a el juego ?le has puesto alguna view al room? si por ejemplo pon?s view_yview+400 y view llega hasta 300 se pasar? y no se va a poder ver.
La room mide 1280x800 pixels.
Jajaja, Masterkey se refiere a la view (http://www.comunidadgm.org/manual_GM/Vistas.htm) del room, no al tama?o del mismo
Hm... ese link servir?a si el manual de cgm tuviera las im?genes bien, pero al parecer estan caidas
Ah, no no, no tiene ninguna View, se ve todo el circuito completo en la misma room y al tama?o que es.
Cita de: Texic en Enero 03, 2011, 10:04:23 PM
Jajaja, Efa se refiere a la view (http://www.comunidadgm.org/manual_GM/Vistas.htm) del room, no al tama?o del mismo
Hm... ese link servir?a si el manual de cgm tuviera las im?genes bien, pero al parecer estan caidas
?porque Efa?
Eh, no, yo he dicho Masterkey, mir? de vuelta
Jajajaj XD
Haber... empecemos de nuevo. Os voy a explicar desde el principio.
He hecho un juego en el que solo hay una room y se ve toda a un tama?o de 1280x800, o sea, sin views. es un juego tipico de cochecillos en el que hay un circuito con una meta. Lo que yo quiero es que cuando llegue el coche a la meta, se obtengan puntos y se reinicie otra vez el juego pero sin que se renueve la energa. Asi hasta que se agote y acabe el juego, ya que los coches y obstaculos del juego te la van quitando si te chocas.
El problema esta en que como se me ve a pantalla completa quiero poner el Score en un sitio del juego y por mucho que lo intento no me sale.
Esa es mi duda.
muchas gracias
Primero un peque?o consejo: s? usas una room muy grande y sin ninguna view es muy probable que no funcione en pc's con resoluciones peque?as. Luego, ?no hab?a quedado solucionado la primera parte?(la de sumar vueltas etc) creo que el problema est? a la hora de dibujar el score, s? ya se declar? el score global(el normal de game maker) no deber?a hacer ning?n problema, te aconsejo que en la acci?n de dibujar el score pruebes escribiendo 0 en "x" y en "y". y te f?jes s? se dibuja en la esquina superior izquierda. Deber?a funcionar sin NING?N problema, a no ser que no sea ah? el problema. Despu?s si s? se dibuja el score v? acomodando los n?meros a t? gusto
Ok. Si quieres que tu score se vea en pantalla, prueba esto:
En Font cr?ate una font: elije arial 16, color diferente al del fondo. Luego, para dibujar scores no necesita ser visible el objeto score.
1. Objeto:score evento: create score=0;
2. Objeto:score evento: draw piece of code: draw_set_font(font0) draw_text(10,10,score)
Haz todo como ac? te muestro y te saldr? dibujado el 0 de score en la izquierda superior de tu juego.
Si no entiendes, avisa. Si te funka igual.
MASTERKEY, pues no me sale por ningun sitio, aunque ahi tengo la barra de energia... no se si sera por eso.
KALIMAN 777, hice lo que me dijiste pero me sale este error:
ERROR in
action number 1
of Draw Event
for object Score:
Error in code at line 1:
draw_set_font(font0) draw_text(10,10,score)
^
at position 15: Unknown variable font0
MUCHAS GRACIAS y perdonad las molestias, pero es que me keda poco para acabar y me gustaria saber porque me esta dando tanta guerra algo que en principio parece sencillo.
Si ah? tienes la barra de energ?a pues entonces mueve el "y" al dibujar el score a 200(por ejemplo) adem?s coloca en donde dice deph en el objeto que dibuja el score -10000 para que dibuje por encima de todo. El c?digo de kaliman777 no funcion? porque no hay ninguna fuente con ese nombre.
BIENNN!!!!!!! ya me sale!! pero la fuente es muy delgada y casi no se ve.
?Como puedo cambiarla?
muchas Gracias!!
Cita de: eric610 en Enero 04, 2011, 06:39:59 PM
MASTERKEY, pues no me sale por ningun sitio, aunque ahi tengo la barra de energia... no se si sera por eso.
KALIMAN 777, hice lo que me dijiste pero me sale este error:
ERROR in
action number 1
of Draw Event
for object Score:
Error in code at line 1:
draw_set_font(font0) draw_text(10,10,score)
^
at position 15: Unknown variable font0
MUCHAS GRACIAS y perdonad las molestias, pero es que me keda poco para acabar y me gustaria saber porque me esta dando tanta guerra algo que en principio parece sencillo.
Es simple: revisa que el nombre de la font que creaste se llama font0, o mira las may?sculas, la F de font. Es tan simple XD.
OK!! Muchisimas Gracias!! este tema esta arreglado!!
ahora solo una duda
?Como hago para que se me mantenga la energia que tengo cuando reinicio de nuevo la room y no se renueve como al principio?
Gracias!!
Podr?as irte del room y volver instant?neamente dejando s?lo el objeto que controla la energ?a como persistente, o declarar la energ?a como global y nuevamente irte del room y volver, o crear un ini q guarde la energ?a para cuando se reinicia el juego, hay tantas maneras...
Abre otro tema para otra preguntas ?son las reglas! ?Por cierto que hiciste para que sirviera?
Ok Masterkey, perdona, es que soy novatillo y voy algo perdido. lo siento.
Pues lo que hice fue crear un evento Draw y desde ahi, ir a draw score y poner x: 400 e y: 15...
Asi de sencillo... ahora funciona, aunque creo que ya lo habiamos intentado...