Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotated and scaled image drawing
#7
Hehe, some quick code, but I'm not sure it will help much, it's just a visual thing:

Code:
#win32

set window "nah ...", 320, 240, false, 2
set redraw off

road = []
for z = 0 to 200  road[z] = sin(z*0.05)*6

playerz = 0.0
playerx = 0
p = dim(8)
while not keydown(KEY_ESCAPE, true)
    playerz = playerz + 0.075
    if keydown(KEY_LEFT)  playerx = playerx - 0.1
    if keydown(KEY_RIGHT) playerx = playerx + 0.1

    set color 64, 64, 128
    cls
    set color 200, 128, 64
    draw rect 0, 125, 320, 120, true
    
    set color 255, 255, 255
    for i = int(playerz) + 20 to int(playerz)
        if i < sizeof(road) - 2
            z = i + 1 - playerz + 1.1
            x0l = 160 + 200*(road[i + 1] - 1 - playerx)/z
            x0r = 160 + 200*(road[i + 1] + 1 - playerx)/z
            y0 = 120 + 130/z
            z = i - playerz + 1.1
            x1l = 160 + 200*(road[i] - 1 - playerx)/z
            x1r = 160 + 200*(road[i] + 1 - playerx)/z
            y1 = 120 + 130/z
            if i%2 = 0  set color 128, 128, 128
            else  set color 96, 96, 96
            p[0] = x0l; p[1] = y0; p[2] = x0r; p[3] = y0
            p[4] = x1r; p[5] = y1; p[6] = x1l; p[7] = y1
            draw poly p, true
        endif
    next
    
    redraw
    fwait 60
wend
Reply


Messages In This Thread
Rotated and scaled image drawing - by Marcus - 03-03-2024, 10:49 AM
RE: Rotated and scaled image drawing - by Marcus - 03-03-2024, 08:25 PM
RE: Rotated and scaled image drawing - by Marcus - 03-06-2024, 04:08 PM
RE: Rotated and scaled image drawing - by Marcus - 03-06-2024, 05:01 PM
RE: Rotated and scaled image drawing - by Marcus - 03-06-2024, 06:20 PM
RE: Rotated and scaled image drawing - by Marcus - 03-10-2024, 01:24 PM
RE: Rotated and scaled image drawing - by Marcus - 03-14-2024, 04:38 PM
RE: Rotated and scaled image drawing - by Marcus - 03-14-2024, 07:00 PM
RE: Rotated and scaled image drawing - by Marcus - 03-15-2024, 09:38 PM
RE: Rotated and scaled image drawing - by kevin - 03-16-2024, 01:19 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)