Author Topic: Manga Background  (Read 4803 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Manga Background
« on: 2006-Jan-04 »
Ever wondered how to draw a inclined mange background - for a highscore table e.g.?
Here's a short mehtod, that wastes some CPU power - if you mind, change it.

Code: (glbasic) [Select]
FILLRECT 0,0, 150,100,RGB(40,70,220)
FILLRECT 0,0, 142,41,RGB(40,220,40)
PRINT "GLBasic", 3,3
GRABSPRITE 0, 1,1,150,46
BLACKSCREEN

WHILE TRUE
MenuBkgRot(0, 32.5, 20)
SHOWSCREEN
WEND

FUNCTION MenuBkgRot: id, phi, speed
LOCAL dx, dy, rx, ry, bx, by, sx, sy, ox, gox
GETSPRITESIZE id, bx, by
IF bx=0 OR by=0 THEN RETURN
bx=bx+2
by=by+3
dx = COS(phi)*bx
dy = - SIN(phi)*bx
rx = SIN(phi)*by
ry =   COS(phi)*by
GETSCREENSIZE sx, sy
bx = INTEGER(sx/bx)*2
by = INTEGER(sy/by)*2
gox = MOD(-GETTIMERALL() * speed, 10000)/10000
FOR y=-by TO by
ox = MOD(y,2)/2 + gox
FOR x=-bx TO bx
ROTOSPRITE id, (x+ox)*dx+y*rx, (x+ox)*dy+y*ry, phi
NEXT
NEXT
ENDFUNCTION
and that's all of it. Have fun.

goomoo

  • Guest
Manga Background
« Reply #1 on: 2006-Mar-19 »
Cool,Thanks Gernot!