Board index » delphi » Visual page / Active page

Visual page / Active page

Can someone explain / send an example of how to use "visual page".

My help file doesn't help very much. All I want to do is a scroll.

  // Erik

 

Re:Visual page / Active page


Quote
Erik Gustafson wrote:

> Can someone explain / send an example of how to use "visual page".

> My help file doesn't help very much. All I want to do is a scroll.

>   // Erik

hm.. lets try it
repeat
setvisualpage(x); show contens
if x=1 then dec(x) else inc(x);
setactivpage(x);
{now write your text again, one line scrolled)
delay(xxxxx) Not to fast to read
delay until text is totaly shown.

hope it might help

Tomy

Tomy_Neum...@t-online.de

Re:Visual page / Active page


This is a multi-part message in MIME format.

--------------1B90667F5C73
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote
Erik Gustafson wrote:

> Can someone explain / send an example of how to use "visual page".

> My help file doesn't help very much. All I want to do is a scroll.

>   // Erik

Below is a reply to a similar message some months back. I hope it has
what you're looking for.

I have attached two samples with the active/visualpage commands.
I won't start a discussion about WHY you're using them (I've only used
them in one program - then always relied on either mode13h (320x200x256)
with four virtual pages but a low resolution or mode12h (640x480x16)
with a high resolution, only 16 colors and no page-flipping - the last
actually is/was my favorite!)

The first example (actvis.pas) shows the basics of the two commands - I
guess you'll be able to understand them from this. The second (clock)
shows a simple implementation which should give you a basic idea of how
you could handle the pages.
Another possibility I haven't illustrated here is running your game on
one page and keeping the second page as info- or help-page at hand. The
advantage of this is that a user can call this page in a split-second
and return to the unaltered game.
I hope this helps you any further.

As to the FastGraph-library: it is supposed to be very good, but it is
not free! I downloaded the shareware (light-version) and tried it out
just now to be able to give you some more information. Halfway the
examples it crashed my system (WITH win95) and my opinion is that I
don't need an expensive library to do that for me. Of what I saw, I
think for the most basic things you don't really need it. If you plan to
do more advanced things with it I'd still recommend you try to find out
how to do it yourself. Then you'll have a better knowledge of the
possibilities and the things that go wrong. I haven't seen a library yet
that is easier to learn then just plain programming.
To be short, if you want to buy it: sure, you'll do great things with
it, but if you're still concerned with pageflipping in bgi-graphics
maybe that's still two steps ahead of you.

That's a bit I'd actually wanted to avoid, but still: if you want to get
into (game-)programming maybe you should consider which 'platform'
you're going to use. By that I mean: do you want to make DOS-games or
Windows-games ( a serious choice!) and if you choose for DOS, do you
want them in SVGA-quality, VGA-mode13h, or the other (bit backward)
VGA-modes. As I said I use(d) VGA-mode12h a lot, but now I'm switching
to SVGA- and Windows-programs too. Mode12h can be great (look at the
game-screenshots on my site) but you should really dive into it.

OK, that'll be all for now, if there's anything more, let me know.

Good luck!

Remco de Korte
Soft Machine
Nederland
http://www.xs4all.nl/~remcodek/softmach.html

PS I attached the SMGRAF-tpu so you can compile the pas-files.

program actvis;

uses
  smgraf,graph,crt;

var
  i:integer;

begin
  initgraf1;
  {This initializes the graphics mode with 640x350 pixels at 16 colors.
   The statement comes from the smgraf-tpu and is just an ordinary
   registerbgi-initialization - put into one statement.}

  setvisualpage(0);
  setactivepage(0);
  outtextxy(10,10,'This is page #0, now visual'); {This you see}
  setactivepage(1);
  outtextxy(10,10,'This is page #1, now visual'); {This you don't}
  outtextxy(10,30,'Preparing page #0... Press a key to flip.');
  setvisualpage(1);                               {...and now you do}

  setactivepage(0);
  for i:=1 to 30000 do
putpixel(random(600)+20,random(300)+40,random(16));
  {drawing pixels on the hidden page}
  outtextxy(10,30,'Preparing page #1... Press a key to flip.');

  readkey;                           {waiting for keypress}
  setvisualpage(0);                  {showing 'pixel-page'}

  setactivepage(1);
  for i:=1 to 1000 do
  begin
    setcolor(random(16));
    line(random(600)+20,random(300)+40,random(600)+20,random(300)+40);
  end;
  {drawing lines on the hidden page}

  readkey;
  setvisualpage(1);                 {showing 'line-page'}

  readkey;
  closegraph;
end.

program clock;

uses
  smgraf,graph,dos,crt;

var
  hour,min,sec,hun:word;
  i,x,y,oldsec:integer;

procedure drawclock;

begin
  cleardevice;
  for i:=1 to 60 do
putpixel(320+trunc(160*sin(i*pi/30)),175-trunc(120*cos(i*pi/30)),darkgray);
  for i:=0 to 12 do
  begin
    x:=320+trunc(160*sin(i*pi/6));
    y:=175-trunc(120*cos(i*pi/6));
    putpixel(x-1,y,lightgray);
    putpixel(x,y-1,lightgray);
    putpixel(x,y,white);
    putpixel(x+1,y,darkgray);
    putpixel(x,y+1,darkgray);
  end;
end;

procedure drawhands;

begin
  {'second hand'}
  setcolor(lightred);

line(320,175,320+trunc(140*sin(sec*pi/30)),175-trunc(105*cos(sec*pi/30)));
  {'minute hand'}
  x:=320+trunc(100*sin(min*pi/30));
  y:=175-trunc(75*cos(min*pi/30));
  setcolor(darkgray);
  line(320-1,175,x-1,y);
  line(320+1,175,x+1,y);
  line(320,175-1,x,y-1);
  line(320,175+1,x,y+1);
  x:=320+trunc(120*sin(min*pi/30));
  y:=175-trunc(90*cos(min*pi/30));
  setcolor(lightgray);
  line(320,175,x,y);
  {'hour hand'}
  x:=320+trunc(100*sin(hour*pi/6));
  y:=175-trunc(75*cos(hour*pi/6));
  setcolor(darkgray);
  line(320-1,175,x-1,y);
  line(320+1,175,x+1,y);
  line(320,175-1,x,y-1);
  line(320,175+1,x,y+1);
  line(320,175,x,y);
end;

procedure drawloop;

begin
  drawclock;
  repeat
    gettime(hour,min,sec,hun);
  until (sec<>oldsec) or (keypressed);
  oldsec:=sec; {this updates the clock only whne necessary, i.e. at
every second}
  drawhands;
end;

begin
  initgraf1;
  gettime(hour,min,sec,hun);
  oldsec:=sec;
  repeat
    setactivepage(0);
    drawloop;
    setvisualpage(0);

    setactivepage(1);
    drawloop;
    setvisualpage(1);
  until keypressed;
  closegraph;
end.

--------------1B90667F5C73
Content-Type: application/octet-stream; name="Smgraf.tpu"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Smgraf.tpu"

<encoded_portion_removed>
--------------1B90667F5C73--

Re:Visual page / Active page


This is a multi-part message in MIME format.

--------------45EF100C586C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote
Erik Gustafson wrote:

> Can someone explain / send an example of how to use "visual page".

> My help file doesn't help very much. All I want to do is a scroll.

>   // Erik

Below is a reply to a similar message some months back. I hope it has
what you're looking for.

I have attached two samples with the active/visualpage commands.
I won't start a discussion about WHY you're using them (I've only used
them in one program - then always relied on either mode13h (320x200x256)
with four virtual pages but a low resolution or mode12h (640x480x16)
with a high resolution, only 16 colors and no page-flipping - the last
actually is/was my favorite!)

The first example (actvis.pas) shows the basics of the two commands - I
guess you'll be able to understand them from this. The second (clock)
shows a simple implementation which should give you a basic idea of how
you could handle the pages.
Another possibility I haven't illustrated here is running your game on
one page and keeping the second page as info- or help-page at hand. The
advantage of this is that a user can call this page in a split-second
and return to the unaltered game.
I hope this helps you any further.

As to the FastGraph-library: it is supposed to be very good, but it is
not free! I downloaded the shareware (light-version) and tried it out
just now to be able to give you some more information. Halfway the
examples it crashed my system (WITH win95) and my opinion is that I
don't need an expensive library to do that for me. Of what I saw, I
think for the most basic things you don't really need it. If you plan to
do more advanced things with it I'd still recommend you try to find out
how to do it yourself. Then you'll have a better knowledge of the
possibilities and the things that go wrong. I haven't seen a library yet
that is easier to learn then just plain programming.
To be short, if you want to buy it: sure, you'll do great things with
it, but if you're still concerned with pageflipping in bgi-graphics
maybe that's still two steps ahead of you.

That's a bit I'd actually wanted to avoid, but still: if you want to get
into (game-)programming maybe you should consider which 'platform'
you're going to use. By that I mean: do you want to make DOS-games or
Windows-games ( a serious choice!) and if you choose for DOS, do you
want them in SVGA-quality, VGA-mode13h, or the other (bit backward)
VGA-modes. As I said I use(d) VGA-mode12h a lot, but now I'm switching
to SVGA- and Windows-programs too. Mode12h can be great (look at the
game-screenshots on my site) but you should really dive into it.

OK, that'll be all for now, if there's anything more, let me know.

Good luck!

Remco de Korte
Soft Machine
Nederland
http://www.xs4all.nl/~remcodek/softmach.html

PS I attached the SMGRAF-tpu so you can compile the pas-files.

program actvis;

uses
  smgraf,graph,crt;

var
  i:integer;

begin
  initgraf1;
  {This initializes the graphics mode with 640x350 pixels at 16 colors.
   The statement comes from the smgraf-tpu and is just an ordinary
   registerbgi-initialization - put into one statement.}

  setvisualpage(0);
  setactivepage(0);
  outtextxy(10,10,'This is page #0, now visual'); {This you see}
  setactivepage(1);
  outtextxy(10,10,'This is page #1, now visual'); {This you don't}
  outtextxy(10,30,'Preparing page #0... Press a key to flip.');
  setvisualpage(1);                               {...and now you do}

  setactivepage(0);
  for i:=1 to 30000 do
putpixel(random(600)+20,random(300)+40,random(16));
  {drawing pixels on the hidden page}
  outtextxy(10,30,'Preparing page #1... Press a key to flip.');

  readkey;                           {waiting for keypress}
  setvisualpage(0);                  {showing 'pixel-page'}

  setactivepage(1);
  for i:=1 to 1000 do
  begin
    setcolor(random(16));
    line(random(600)+20,random(300)+40,random(600)+20,random(300)+40);
  end;
  {drawing lines on the hidden page}

  readkey;
  setvisualpage(1);                 {showing 'line-page'}

  readkey;
  closegraph;
end.

program clock;

uses
  smgraf,graph,dos,crt;

var
  hour,min,sec,hun:word;
  i,x,y,oldsec:integer;

procedure drawclock;

begin
  cleardevice;
  for i:=1 to 60 do
putpixel(320+trunc(160*sin(i*pi/30)),175-trunc(120*cos(i*pi/30)),darkgray);
  for i:=0 to 12 do
  begin
    x:=320+trunc(160*sin(i*pi/6));
    y:=175-trunc(120*cos(i*pi/6));
    putpixel(x-1,y,lightgray);
    putpixel(x,y-1,lightgray);
    putpixel(x,y,white);
    putpixel(x+1,y,darkgray);
    putpixel(x,y+1,darkgray);
  end;
end;

procedure drawhands;

begin
  {'second hand'}
  setcolor(lightred);

line(320,175,320+trunc(140*sin(sec*pi/30)),175-trunc(105*cos(sec*pi/30)));
  {'minute hand'}
  x:=320+trunc(100*sin(min*pi/30));
  y:=175-trunc(75*cos(min*pi/30));
  setcolor(darkgray);
  line(320-1,175,x-1,y);
  line(320+1,175,x+1,y);
  line(320,175-1,x,y-1);
  line(320,175+1,x,y+1);
  x:=320+trunc(120*sin(min*pi/30));
  y:=175-trunc(90*cos(min*pi/30));
  setcolor(lightgray);
  line(320,175,x,y);
  {'hour hand'}
  x:=320+trunc(100*sin(hour*pi/6));
  y:=175-trunc(75*cos(hour*pi/6));
  setcolor(darkgray);
  line(320-1,175,x-1,y);
  line(320+1,175,x+1,y);
  line(320,175-1,x,y-1);
  line(320,175+1,x,y+1);
  line(320,175,x,y);
end;

procedure drawloop;

begin
  drawclock;
  repeat
    gettime(hour,min,sec,hun);
  until (sec<>oldsec) or (keypressed);
  oldsec:=sec; {this updates the clock only whne necessary, i.e. at
every second}
  drawhands;
end;

begin
  initgraf1;
  gettime(hour,min,sec,hun);
  oldsec:=sec;
  repeat
    setactivepage(0);
    drawloop;
    setvisualpage(0);

    setactivepage(1);
    drawloop;
    setvisualpage(1);
  until keypressed;
  closegraph;
end.

--------------45EF100C586C
Content-Type: application/octet-stream; name="Smgraf.tpu"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Smgraf.tpu"

<encoded_portion_removed>
--------------45EF100C586C--

Other Threads