Entrar
¿Usuario nuevo? Regístrate
allegro-espanol · Una lista en español sobre la librería Allegro.
? ¿Ya estás suscrito? Entrar en Yahoo!

Consejos de Yahoo! Grupos

¿Sabías que...?
Puedes buscar mensajes antiguos en un grupo.

Mensajes

  Mensajes Ayuda
Avanzado
Re: [AL-ES] Scroll   Lista de mensajes  
Responder | Reenviar Mensaje #666 de 9896 |
Que yo sepa windows no admite scroll por hardware, es decir el sistema windows no lo puede hacer y a lo mejor la tarjeta si como bien dices.
de todas maneras esto te lo debería confirmar los diseñadores de Allegro (y a mi también).
 
En sistemas Linux no me caliento con el scroll por hardware, así me despreocupo del sistema físico, aunque el código sea un poco más longilíneo.
 
A continuación os muestro como  implemento el scroll en mis juegos, espero que os sea útil.
 
/*------------------------------------------------------------
   John Alexis Guerra Gómez <aguerra@...>
   JFHorizon                         <jfhorizon@...>
------------------------------------------------------------*/
 
#include <string.h>
#include <stdio.h>
 
#define ALLEGRO_STATICLINK
#include<allegro.h>
 
BITMAP *buffer_screen;
BITMAP *buffer_escena;
 
typedef struct scroll_
{
        int x0;         // Coordenadas del primer plano
        int y0;
}SCROLL_T;
 
SCROLL_T *scroll;
 
void reserve_memory_scroll(int num_scrolles)
{
   if ((scroll = (SCROLL_T *) malloc(num_scrolles * sizeof(SCROLL_T) ))== NULL)
   {
       allegro_message("Modo grafico no detectado \n%s\n", allegro_error);
       exit(4);
   }
 
   // Inicializa la estructura de scroll.
   memset(scroll, 0, num_scrolles * sizeof(SCROLL_T));
}
 
// -------------------------------------------------------------------------
// Mueve e inicializa el scroll por software
// -------------------------------------------------------------------------
void Scroll(int num_scroll, BITMAP *escenario_entra, int new_x0, int new_y0, int new_camera)
{
    if (new_camera==0)     // Camara en vision general (al mouse)
    {
        if (new_x0>=0 && new_y0>=0 && new_x0<=(128+escenario_entra->w/2)
            && new_y0<=escenario_entra->h/2)
        {
            scroll[num_scroll].x0= new_x0;                       // region 01
            scroll[num_scroll].y0= new_y0;
        }
 
        if (new_x0>=(128+escenario_entra->w/2) && new_y0>=0
            && new_x0<=(128+escenario_entra->w) && new_y0<=escenario_entra->h/2)
        {
            scroll[num_scroll].x0=128+escenario_entra->w/2;      // region 02
            scroll[num_scroll].y0=new_y0;
        }
 
        if (new_x0>=0 && new_y0>=escenario_entra->h/2 && new_x0<=(128+escenario_entra->w/2)
            && new_y0<=escenario_entra->h)
        {
            scroll[num_scroll].x0=new_x0;                        // region 03
            scroll[num_scroll].y0=escenario_entra->h/2;
        }
 
        if (new_x0>=(128+escenario_entra->w/2) && new_y0>=escenario_entra->h/2
            && new_x0<=escenario_entra->w && new_y0<=escenario_entra->h)
        {
            scroll[num_scroll].x0=128+escenario_entra->w/2;      // region 04
            scroll[num_scroll].y0=escenario_entra->h/2;
        }
 
        if (new_x0>=0 && new_y0<0 && new_x0<=(128+escenario_entra->w/2))
        {
            scroll[num_scroll].x0=new_x0;                        // region 05
            scroll[num_scroll].y0=0;
        }
 
        if (new_x0>=(128+escenario_entra->w/2) && new_y0<=0 && new_x0<=escenario_entra->w)
        {
            scroll[num_scroll].x0=128+escenario_entra->w/2;      // region 06
            scroll[num_scroll].y0=0;
        }
 
        if (new_x0>=escenario_entra->w && new_y0<=escenario_entra->h/2)
        {
            scroll[num_scroll].x0=128+escenario_entra->w/2;      // region 07
            scroll[num_scroll].y0=0;
        }
 
        if (new_x0>=escenario_entra->w && new_y0>=escenario_entra->h/2
            && new_y0<=escenario_entra->h)
        {
            scroll[num_scroll].x0=128+escenario_entra->w/2;      // region 08
            scroll[num_scroll].y0=escenario_entra->h/2;
        }
 
        if (new_x0>=(128+escenario_entra->w/2) && new_x0<=escenario_entra->w
            && new_y0>=escenario_entra->h)
        {
            scroll[num_scroll].x0=128+escenario_entra->w/2;      // region 09
            scroll[num_scroll].y0=escenario_entra->h/2;
        }
 
        if (new_x0>=0 && new_x0<=(128+escenario_entra->w/2) && new_y0>=escenario_entra->h)
        {
            scroll[num_scroll].x0=0;                             // region 10
            scroll[num_scroll].y0=escenario_entra->h/2;
        }
 
        if (new_x0<=0 && new_y0>=0 && new_y0<=escenario_entra->h/2)
        {
            scroll[num_scroll].x0=0;                             // region 11
            scroll[num_scroll].y0=new_y0;
        }
 
        if (new_x0<=0 && new_y0>=escenario_entra->h/2 && new_y0<=escenario_entra->h)
        {
            scroll[num_scroll].x0=0;                             // region 12
            scroll[num_scroll].y0=escenario_entra->h/2;
        }
 
        if (new_x0<=0 && new_y0<=0)
        {
            scroll[num_scroll].x0=0;                             // region 13
            scroll[num_scroll].y0=0;
        }
 
        if (new_x0>escenario_entra->w && new_y0<=0)
        {
            scroll[num_scroll].x0=escenario_entra->w/2;          // region 14
            scroll[num_scroll].y0=0;
        }
 
        if (new_x0>escenario_entra->w && new_y0>escenario_entra->h)
        {
            scroll[num_scroll].x0=128+escenario_entra->w/2;      // region 15
            scroll[num_scroll].y0=escenario_entra->h/2;
        }
 
        if (new_x0<=0 && new_y0>escenario_entra->h)
        {
            scroll[num_scroll].x0=0;                             // region 16
            scroll[num_scroll].y0=escenario_entra->h/2;
        }                                                                                          //   640-128, 480
    }
 
    // Refrescar la escena.
    masked_blit(escenario_entra, buffer_screen, scroll[0].x0, scroll[0].y0, 0, 0, 640, 480);
}
 
void main()
{
        int i;
        register int velx=0, vely=0;
        register int x, y;
 
        allegro_init();
        install_timer();
        install_mouse();
        install_keyboard();
 
        if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0)<0)
        {
           allegro_message("Modo grafico no detectado \n%s\n", allegro_error);
           allegro_exit();
        }
 
        // Inicializa scroll
        reserve_memory_scroll(1);
 
        // Creamos bitmap para la pantalla
        buffer_screen=create_bitmap(SCREEN_W, SCREEN_H);
        if(!buffer_screen)
        {
           allegro_message("Disculpa, no hay memoria disponible \n%s\n", allegro_error);
           allegro_exit();
        }
 
        // Creamos bitmap para la escena
        buffer_escena=create_bitmap(1600, 1200);
        if(!buffer_escena)
        {
           allegro_message("Disculpa, no hay memoria disponible para la escena \n%s\n", allegro_error);
           allegro_exit();
        }
 
        // pintamos la escena
        for(i=0; i<=100; i++)
        {
            vline(buffer_escena, i*16,   0, 1200, i);
            hline(buffer_escena, 0   ,i*12, 1600, i);
        }
       
        // nos colocamos en la escena en este caso en el mismo centro.
        scroll[0].x0= 1600/2-SCREEN_W/2;
        scroll[0].y0= 1200/2-SCREEN_H/2;
 
        while(!key[KEY_ESC])
        {
              x= mouse_x+scroll[0].x0;
              y= mouse_y+scroll[0].y0;
 
              if (mouse_x<= 20 && velx>-16)  { velx-=4; }
              if (mouse_x>=620 && velx< 16)  { velx+=4; }
              if (mouse_y<= 20 && vely>-16)  { vely-=4; }
              if (mouse_y>=460 && vely< 16)  { vely+=4; }
 
              scroll[0].x0= scroll[0].x0+velx;
              scroll[0].y0= scroll[0].y0+vely;
 
              Scroll(0, buffer_escena, scroll[0].x0, scroll[0].y0, 0);  
 
              if (velx>0) {velx-=2; }
              if (vely>0) {vely-=2; }
              if (velx<0) {velx+=2; }
              if (vely<0) {vely+=2; }
 
              show_mouse(buffer_screen);
              blit(buffer_screen, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
              show_mouse(NULL); 
 
        }
 
        destroy_bitmap(buffer_screen);
        destroy_bitmap(buffer_escena);
        free(scroll);
 
        allegro_exit();
}
END_OF_MAIN();
 
Para cualquier aclaración a disposición y cordial saludo a todos
Jfhorizon
----- Original Message -----
Sent: Monday, March 04, 2002 5:49 PM
Subject: [AL-ES] Scroll

Saludos lista, resulta que estoy tratando un pequeño juego de carros,
con scroll pero no lo logro hacer funcionar, alguien me puede decir en
que me equivoco

#include<allegro.h>

void main()
{
        allegro_init();
        install_timer();
        install_mouse();
        install_keyboard();
        set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0);
        for(int i=0;i<=100;i++)
        {
                vline(screen,i*16,0,1200,i);
                hline(screen,0,i*12,1600,i);
        }
        int j;
        show_mouse(screen);
        while(!key[KEY_ESC])
        {
                j=scroll_screen(mouse_x,mouse_y);
                textprintf(screen,font,100,100,100,"%i gfx=%i vx=%i
sx=%i"
                                ,j,GFX_CAN_SCROLL,VIRTUAL_W,SCREEN_W);
        }
        allegro_exit();
}
END_OF_MAIN();

gracias, resulta que no me hace el scroll y me aparece como salida del
textprintf

-1 gfx=1 vx=800 sx=800

lo que interpreto como que no pudo hacer el scroll_screen, pero que la
tarjeta si la soporta.

Además me podrían explicar los valores de VIRTUAL_W y VIRTUAL_H, ya que
no los entiendo del todo.

Tengo Mandrake 8.1+ Allegro 4.0 y la tarjeta de video es una ABIT Siluro
T400 (GeForce2 MX400)

Gracias John

~
~
~                         




_______________________________________________
Para cancelar su subscripción envíe un email a:
allegro-espanol-unsubscribe@egroups.com


La utilización de Yahoo! Grupos está sujeta a su aceptación de las Condiciones del servicio así como de la Política de privacidad.


Mié, 6 de Mar, 2002 4:05 pm

jfhorizon@...
Enviar mensaje Enviar mensaje

Reenviar Mensaje #666 de 9896 |
Desplegar mensajes Autor Ordenar por fecha

Que yo sepa windows no admite scroll por hardware, es decir el sistema windows no lo puede hacer y a lo mejor la tarjeta si como bien dices. de todas maneras...
José Fernando P...
jfhorizon@...
Enviar mensaje
6 de Mar, 2002
4:06 pm

Esta es solamente una disculpa para mejorar un poco el código sobre el scroll, así como una ampliación donde introducimos los círculos arcoiris de allegro....
José Fernando P...
jfhorizon@...
Enviar mensaje
6 de Mar, 2002
7:57 pm

Que yo sepa windows no admite scroll por hardware, es decir el sistema windows no lo puede hacer y a lo mejor la tarjeta si como bien dices. de todas maneras...
José Fernando P...
fernando.perez@...
Enviar mensaje
7 de Mar, 2002
1:40 am
Avanzado

Copyright © 2009 Yahoo! Todos los derechos reservados.
Política de Privacidad Actualizada - Condiciones del servicio - Directrices - Ayuda