Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Large monchronome map scrolling engine (your opinion please)
#1
This is about a map scrolling engine that I've thought of while writing an article for QBE. I first doubted if it was fast enough, but I'm very enthousast now, because it runs at 100 fps(compiled of course) on a good computer.
The engine doen't look good, but look beneath that and look at the possibilities. I will add a texture soon and a landscape instead of just black and blue dots.

Here is my monchronome map scroller. I doesn't work with tiles, but with 2 colour pixels. This example may suck because I haven't made a map editor yet. Probably I will make one soon in screen 12. Anyway, it is scrolling a map that is 8 times larger then the screen. The pixels are just random and that looks shitty, but imagine how nice it could be if the pixels are placed in some kind of landscape.

This engine can be used with tiles also, so that you can see only the coloured pixels on the map, so textures actually are supported. It is also going to be possible to edit the map in realtime, so that it is going to be possible to make some worms-style engine with it(what is the intension).

I think I will release a demo soon that uses this with a texture and with a landscape. But I first have to make the map editor.

This may going to be used in a worms-like engine. I wrote an article on that(in the QBE that is not out yet), where this technique is described. I did some optimization though.
Well, I'll give you the code:
<Look at the note I made about compiling>
Code:
REM Scroll.bas
REM ______________________________
REM Testcase for monochrome engine
REM Can scroll a map with monchronome pixels
REM The map can be up to 8 times the screen
REM But only supports two color(back and foreground)
REM Made by Codemss
REM
REM May be used for learning purposes
REM But if you copy ANY of this code
REM I want credit
REM
REM Greets,
REM Codemss
REM ______________________________
REM BTW
REM I wrote a article about this for the QBE
REM (QBasic Express), but it has not yet came out
REM
REM I will send a new version with this code included to Pete
REM I am very happy because in the article I doubted if it was
REM possible to use this technique at high speed
REM but I got 100 fps on a pentium 4.
REM So I think it is fast enough
REM ______________________________

DECLARE SUB drawrow (x%, y%)
DECLARE FUNCTION getpix% (x%, y%)
CLS
SCREEN 13
DEFINT A-Z
REM $DYNAMIC

REM IMPORTANT: IF YOU WANT TO COMPILE, MAKE THESE INTEGERS!!
REM THIS IS FASTER AND ELSE IT PROBABLY WONT WORK
REM DO NOT MAKE THE WHOLE LINE A COMMENT AS THE VARIABLES
REM STILL NEED TO BE SHARED!

DIM SHARED p AS LONG
DIM SHARED offset AS LONG
DIM SHARED mul320(319) AS LONG

CONST xsize = 320 * 8 - 1

DIM SHARED buf(31999), bufseg
bufseg = VARSEG(buf(0))

DIM SHARED ntb(255, 7)
FOR n = 0 TO 255
  FOR b = 0 TO 7
    IF (n AND (2 ^ b)) THEN ntb(n, b) = 1
  NEXT
NEXT

DIM SHARED lut(319)

DIM SHARED bitnum(xsize)
DIM SHARED bytenum(xsize)
FOR x = 0 TO xsize
  bitnum(x) = x AND 7
  bytenum(x) = x \ 8
NEXT

FOR y = 0 TO 319
  mul320(y) = 320& * y
NEXT

DEF SEG = bufseg
FOR y = 0 TO 199
  FOR x = 0 TO 319
    POKE p, INT(RND * 256)
    p = p + 1
  NEXT
NEXT

t1! = TIMER
DO UNTIL LEN(INKEY$)
  p = 0
  FOR y = 0 TO 199
    drawrow a, y
  NEXT
  a = a + 1
  IF a > xsize - 319 THEN EXIT DO
LOOP
t2! = TIMER
PRINT a / (t2! - t1!)
DEF SEG
SLEEP

REM $STATIC
SUB drawrow (x, y)
offset = bytenum(x) + mul320(y)
bit = bitnum(x)
xx = 0
DO
  value = PEEK(offset)
  FOR b = bit TO 7
    lut(xx) = ntb(value, b)
    IF xx = 319 THEN EXIT DO
    xx = xx + 1
  NEXT
  bit = 0
  offset = offset + 1
LOOP
DEF SEG = &HA000
FOR xx = 0 TO 319
  POKE p, lut(xx)
  p = p + 1
NEXT
DEF SEG = bufseg
END SUB
Reply
#2
I don't know why you haven't had anyone comment on your program yet.  Me, I am not into graphics, very much, so I can't give you any good advice or suggestions.  However, it seems to do exactly what you say, very well. 

Please continue with your stated intentions, and keep posting, here.  A guru or two should, hopefully, note your good efforts and join in with some helpful ideas! Smile
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)