Display3 Questions 
Author Message
 Display3 Questions

Hello,

I'm currently doing a computer science project where we have to create
an interactive maze game in Oberon. I've created basic Gadget to display
my maze, but I can't quite figure out what value to pass to  
Display3.Line's pat parameter other that Display3.selectpat.

Also, what is the best way to quickly redraw my gadget when it is
requested to do so by the Oberon system? Is there some way I can make a
copy of what is displayed on the Gadget in memory, and just write that
image to the part of the gadget that is visible every time?

Thanks in advance.

Regards,

Albert



Wed, 29 Oct 2003 17:42:20 GMT  
 Display3 Questions
You can create your own patterns using the Display.NewPattern command.
You pass it the desired width and height and a pattern specified by
an array of sets.  The SET constructor in Oberon is a bit clunky for
defining a bitmap, so I wrote my own.

  PROCEDURE SetFromStr(str : ARRAY 32 OF CHAR):SET;
  VAR
    returnSet : SET;
    i : INTEGER;

  BEGIN
    returnSet := {};
    FOR i := 0 TO 31 DO;
      IF str[i] = "*" THEN INCL(returnSet, i); END;
    END;
  END SetFromStr;

  PROCEDURE Restore(F: Frame; Q: Display3.Mask; x, y, w, h: INTEGER);
  VAR
    pattern : Display.Pattern;
    image : ARRAY 8 OF SET;

  BEGIN
    image[0] := SetFromStr("-------**-------");
    image[1] := SetFromStr("------****------");
    image[2] := SetFromStr("-----******-----");
    image[3] := SetFromStr("----********----");
    image[4] := SetFromStr("---**********---");
    image[5] := SetFromStr("------****------");
    image[6] := SetFromStr("------****------");
    image[7] := SetFromStr("-----*******----");                                              

    pattern := Display.NewPattern(16, 8, image);
    Display3.FillPattern(Q, F.col, pattern, 0, 0, x, y, w, h, Display.replace);

    IF Gadgets.selected IN F.state THEN
      Display3.FillPattern(Q, Display3.white, Display3.selectpat, x, y, x, y, w, h, Display.paint)
    END
  END Restore;

Using the Display.Pattern is a bit of a cludgy way to do bit-mapped graphics.
You can only specify one color at a time.  If you wanted to do multiple colors
you would have to store different "subpatterns" for each different color that
you wanted and then make multiple calls to draw one image.  This might save
memory in some cases (you image only have a few color although you are in
true color mode), but it would definitely be slower.

Gfx is probably a better solution.  In Gfx you can specify images directly
from bitmap files (Pict, JPG, GIF ect).  See:

http://www.oberon.ethz.ch/software/Gfx.html



Quote:
>Hello,

>I'm currently doing a computer science project where we have to create
>an interactive maze game in Oberon. I've created basic Gadget to display
>my maze, but I can't quite figure out what value to pass to  
>Display3.Line's pat parameter other that Display3.selectpat.

>Also, what is the best way to quickly redraw my gadget when it is
>requested to do so by the Oberon system? Is there some way I can make a
>copy of what is displayed on the Gadget in memory, and just write that
>image to the part of the gadget that is visible every time?

>Thanks in advance.

>Regards,

>Albert

_______________________________________________
Submitted via WebNewsReader of http://www.interbulletin.com


Fri, 31 Oct 2003 23:43:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Questions-Questions-Questions-Answers-Answers

2. Question(Questions, questions...)

3. Newbie Question: Realbasic Question

4. Questions Questions

5. Questions and more questions...

6. Browse Question / Report question

7. ***Data buffering question. Long post, lots of questions

8. questions, questions!

9. Questions, questions!

10. MicroWorlds Pro "QUESTION Set Size" question

11. OS/2 REXX Question (Object REXX Question Inside)

12. Doc question and Mount question

 

 
Powered by phpBB® Forum Software