elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.


Tema destacado: ¿Eres usuario del foro? Ahora tienes un Bot con IA que responde preguntas. Lo puedes activar en tu Perfil


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Agregar cansancio.
0 Usuarios y 4 Visitantes están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Agregar cansancio.  (Leído 74 veces)
Tachikomaia


Desconectado Desconectado

Mensajes: 1.833


Hackentifiko!


Ver Perfil
Agregar cansancio.
« en: Ayer a las 19:25 »

Esto es para un juego de carreras, aún no agregué cansancio:
Código
  1. fscommand ("fullscreen", "true");
  2. // Estadísticas:
  3. DKMarioMaxStamina = 1000;
  4. DKMarioMaxSpeed = 0.5;
  5. DKMaxStamina = 500;
  6. DKMaxSpeed = 0.7;
  7. // /////////////////////////////////////////////
  8. // //////////////////  Most  ///////////////////
  9. // /////////////////////////////////////////////
  10. function FaceRight (id) {
  11. if (eval(id+".Facing") == -1) {
  12. set (id+".Facing", 1);
  13. eval(id)._xscale = 100;
  14. }
  15. }
  16. function FaceLeft (id) {
  17. if (eval(id+".Facing") == 1) {
  18. set (id+".Facing", -1);
  19. eval(id)._xscale = -100;
  20. }
  21. }
  22. // /////////////////////////////////////////////
  23. // /////////////////  DKMario  /////////////////
  24. // /////////////////////////////////////////////
  25. function ControlDKMario () {
  26. // Aumentar su Stamina si no está al máximo:
  27. if (Player.Stamina<DKMarioMaxStamina) {
  28. Player.Stamina++;
  29. }
  30. if (Key.isDown(39)) {
  31. // Si se presiona derecha:
  32. eval("RightWhen"+Player.Action)();
  33. } else if (Key.isDown(37)) {
  34. // Izquierda:
  35. eval("LeftWhen"+Player.Action)();
  36. } else {
  37. // Nada:
  38. eval("QuietWhen"+Player.Action)();
  39. }
  40. Player.Turn = Player.Turn+Math.abs(Player.Speed)*0.6;
  41. if (Player.Turn>=10) {
  42. Player.Turn = Player.Turn-10;
  43. Player.Movie.play();
  44. }
  45. }
  46. // When Quiet:
  47. function RightWhenQuiet () {
  48. StartToWalk();
  49. WalkToRight();
  50. }
  51. function LeftWhenQuiet () {
  52. StartToWalk();
  53. WalkToLeft();
  54. }
  55. // When Walking:
  56. function RightWhenWalking () {
  57. WalkToRight();
  58. if (Player.hitTest(MetaDePlayer) == true) {
  59. Player.Meta = true;
  60. removeMovieClip(MetaDePlayer);
  61. }
  62. }
  63. function LeftWhenWalking () {
  64. WalkToLeft();
  65. if (Player.Meta == true && Player.hitTest(AliadoDePlayer) == true) {
  66. gotoAndStop(4);
  67. }
  68. }
  69. function QuietWhenWalking () {
  70. Player.Action = "Quiet";
  71. Player.Speed = 0;
  72. }
  73. // To whens:
  74. function StartToWalk () {
  75. Player.Action = "Walking";
  76. Player.gotoAndStop(2);
  77. }
  78. function WalkToRight () {
  79. Player.Speed = (Player.Speed + DKMarioMaxSpeed)/2;
  80. Player._x = Player._x+Player.Speed;
  81. FaceRight("Player");
  82. }
  83. function WalkToLeft () {
  84. Player.Speed = (Player.Speed - DKMarioMaxSpeed)/2;
  85. Player._x = Player._x+Player.Speed;
  86. FaceLeft("Player");
  87. }
  88. // /////////////////////////////////////////////
  89. // ///////////////////  DK  ////////////////////
  90. // /////////////////////////////////////////////
  91. function IAActs () {
  92. if (IA.Stamina < IA.MaxStamina) {
  93. IA.Stamina++;
  94. }
  95. IA.Tic = Math.abs(IA.Speed)*0.3;
  96. IA.Speed = (IA.Speed + IA.MaxSpeed)/2;
  97. IA._x = IA._x+IA.Speed;
  98. IA.Turn = IA.Turn+IA.Tic;
  99. if (IA.Turn>=10) {
  100. IA.Turn = IA.Turn-10;
  101. IA._xscale = IA._xscale*-1;
  102. }
  103. }

Quiero agregarlo, o sea:
- Que el personaje al moverse pierda stamina.
- Cuando queda con 10 o menos, quede en estado de cansado, sin poder moverse, pero recupere stamina y vuelva a su estado normal cuando tenga 50 o más.
- Cuando queda quieto también recupere.

No parece difícil pero la animación de caminar se estaba ejecutando aunque el personaje está cansado, intentaba arreglar eso hasta que me lié:
Código
  1. // /////////////////////////////////////////////
  2. // /////////////////  DKMario  /////////////////
  3. // /////////////////////////////////////////////
  4. function ControlDKMario () {
  5. // Aumentar su Stamina si no está al máximo:
  6. if (Key.isDown(39)) {
  7. // Si se presiona derecha:
  8. if (Player.Stamina > 50) {
  9. Player.Stamina--;
  10. eval("RightWhen"+Player.Action)();
  11. }
  12. } else if (Key.isDown(37)) {
  13. // Izquierda:
  14. if (Player.Stamina > 50) {
  15. Player.Stamina--;
  16. eval("LeftWhen"+Player.Action)();
  17. }
  18. } else {
  19. // Nada:
  20. eval("QuietWhen"+Player.Action)();
  21. }
  22. Player.Turn = Player.Turn+Math.abs(Player.Speed)*0.6;
  23. if (Player.Turn>=10) {
  24. Player.Turn = Player.Turn-10;
  25. Player.Movie.play();
  26. }
  27. }
  28. // When Quiet:
  29. function RightWhenQuiet () {
  30. StartToWalk();
  31. WalkToRight();
  32. }
  33. function LeftWhenQuiet () {
  34. StartToWalk();
  35. WalkToLeft();
  36. }
  37. function QuietWhenTired () {
  38. if (Player.Stamina < DKMarioMaxStamina) {
  39. Player.Stamina++;
  40. }
  41. }
  42. function QuietWhenQuiet () {
  43. if (Player.Stamina < DKMarioMaxStamina) {
  44. Player.Stamina++;
  45. }
  46. }
  47. // When Walking:
  48. function RightWhenWalking () {
  49. WalkToRight();
  50. }
  51. function LeftWhenWalking () {
  52. WalkToLeft();
  53. }
  54. function QuietWhenWalking () {
  55. Player.Action = "Quiet";
  56. Player.Speed = 0;
  57. }
  58. // To whens:
  59. function StartToWalk () {
  60. Player.Action = "Walking";
  61. Player.gotoAndStop(2);
  62. }
  63. function WalkToRight () {
  64. Player.Speed = (Player.Speed + DKMarioMaxSpeed)/2;
  65. Player._x = Player._x+Player.Speed;
  66. FaceRight("Player");
  67. if (Player.hitTest(MetaDePlayer) == true) {
  68. Player.Meta = true;
  69. removeMovieClip(MetaDePlayer);
  70. }
  71. }
  72. function WalkToLeft () {
  73. Player.Speed = (Player.Speed - DKMarioMaxSpeed)/2;
  74. Player._x = Player._x+Player.Speed;
  75. FaceLeft("Player");
  76. if (Player.Meta == true && Player.hitTest(AliadoDePlayer) == true) {
  77. gotoAndStop(4);
  78. }
  79. }
  80. function Tired () {
  81. Player.Action = "Tired";
  82. Player.Speed = 0;
  83. }
  84.  
  85.  

Además la idea no me está resultando buena, no sé por qué.
Estaba poniendo que sólo puede moverse si tiene stamina 50 o más, pero entonces llega un punto en que se mueve un poquito (en teoría), ya no puede moverse, y se repite. Para que el descanso sea más largo supongo que lo soluciona lo que comenté con guiones, pero no suena realista que te puedas cansar mucho pero luego cuando estás un poco cansado no te puedas mover hasta quedar normal, no sé si me explico.
Puedes gastar energía hasta que sólo te queda 10. Pero entonces hasta que tengas 50 no puedes gastar. ¿Por qué antes sí? No tiene mucha lógica. Lo que se me ocurre ahora es que cuando tienes 50 si te mueves la energía te queda en 0 porque el organismo se enfoca en recuperarse, cierto sentido tiene ¿no?

Lo intentaré hacer más despacio a ver si me sale. Los leo.


« Última modificación: Ayer a las 19:35 por Tachikomaia » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Voto por Internet: un arma contra el cansancio electoral en el 'país de los ....
Noticias
wolfbcn 0 1,712 Último mensaje 30 Junio 2013, 21:40 pm
por wolfbcn
¿Les ha pasado esto por cansancio? « 1 2 »
Foro Libre
flacc 19 8,907 Último mensaje 28 Marzo 2014, 20:59 pm
por 1mpuls0
Cansancio frente a la computadora
Hardware
PC Tips 0 2,227 Último mensaje 21 Abril 2015, 07:06 am
por PC Tips
Este software te ayuda a reducir el cansancio de la vista por las noches
Noticias
wolfbcn 0 1,924 Último mensaje 5 Junio 2015, 21:38 pm
por wolfbcn
Firelux es el f.lux de Firefox para reducir el cansancio de la vista
Noticias
wolfbcn 0 1,924 Último mensaje 23 Marzo 2016, 22:07 pm
por wolfbcn
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines