none
Small Basic Community Challenge: Want to turn this 3D Maze into an RPG? RRS feed

  • General discussion

  • So here's my challenge to the talented Old Basic Coder and to anyone else (see his notes in the thread below).

    The challenge is to Old Basic Coder and the community to add RPG elements to the RayCaster Maze...

    3D Color RayCaster Maze - by Old Basic Coder

    Updated: 5/29/13

    Improvements:

    1. Included VERY simple textures (height of 1 and width of 60) with little slow down. There is even a "door" texture now present. The texture colours also fade to black. :-)
    2. Changed the viewing angle, so that the player's view is higher.
    3. Optimised the code in a number of place.

    Here are my challenges (any of these would be sweet):

    1. NPC characters give you hints to finish the maze.
    2. Timed to finish the maze.
    3. You find items that give you abilities (like speed).
    4. #3 plus items that help you through obstacles (like a key to open a door, a ladder to cross a pit, jump boots to jump over a pit, strength gloves to move a box out of the way, etc.).
    5. Enemies with RPG turn-based fighting.
    6. #5 plus use items or attack choices.
    7. #6 plus experience levels.

    So there you go! Talk about an extreme challenge! I'll sticky this if anyone shows interest. Here are Old Basic Coder's words...

      

    I made a "3D Maze" type program as an exercise. Had not programmed anything for about 25 years, fancied getting back into it, and downloaded the free version of Visual Studio. It popped up with the option of SmallBasic, so I thought I'd start there first.

    My first attempt at the 3D maze has been uploaded to program ID - DWV967

    However, I wanted to develop this further into something that resembled the old Bard's Tale games and have some simple textured walls/graphics. But couldn't work out how to transform and project the textures in software alone. I then read about RayCasting being an efficient method of portraying a simple pseudo 3d world made from blocks, with the ability to map simple textures.

    Found a tutorial at lodev.org with some sample C++ code. I eventually worked out how to translate this into Smallbasic (have never coded C++ before!!) and managed to get the basic engine working.

    After that, I made some improvements to the code (though it is still a bit messy, could probably be optimised and needs more annotation), and included colour shading that gets darker the further away the walls are.

    My RayCaster Maze has been uploaded to program ID - RVR504

    It's probably not running fast enough to include textures within SmallBasic, which would probably benefit from some type of screen buffering (double buffering?) but am now very keen to see if I can port this to my Nexus 7 using "RFO Basic!", include textures and eventually some basic RPG elements too.


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!


    Wednesday, May 22, 2013 6:47 PM
    Owner

All replies

  • Thanks for issuing this challenge Ed. 

    My next steps were to tidy up the code a bit, annotate it a bit more, and to alter the distance shading - I wanted the colours to drop off to black, the further away they were. 

    I've uploaded a slightly updated version as program code:- RVR504

    In terms of the challenge, this would take me weeks to get to cover all of the elements, though it was my intention to eventually include some RPG elements to the "game". I used to love playing The Bard's Tale years ago, and wanted to make something along those principles. 

    To include obstacles, or objects within the Raycaster maze would take a while (if just using native Smallbasic commands, rather than extensions), but I'll try to work on it. :-)

    If anyone wants to include some or all of the challenges above, then feel free. I look forward to seeing the ways this can be improved and other game elements included.

    Thanks

    Wednesday, May 22, 2013 7:00 PM
  • One more thing I was thinking of adding was inertia when moving or rotating, so that movement appears more natural......

    another thing to add to my "to do" list.

    Wednesday, May 22, 2013 7:02 PM
  • Sounds good. I'll pin/sticky this thread and see if anyone wants to join you. If anyone wants to join, use Old Basic Coder's updated version (RVR504) and sync with him so that there's only one version (or combined into one version).

    I loved the Bard's Tale! It would be interesting to see what's possible without extensions, but ultimately extensions are fine. It just means that it won't work in the Web.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Wednesday, May 22, 2013 8:28 PM
    Owner
  • This is a really interesting program and challenge! I had no idea that a program like this could even be created in Small Basic. Amazing!

    I see that the "world" is implemented as a 2D array. I would like to play with this over the weekend and see what I can contribute. Maybe I can adapt my Obstacle Avoidance/Maze Traversal routine from Chomper (Pacman), which I designed for use with a 2D array. This would allow any enemy sprites to move about the game world in the background. It's worth a try.

    I'll everyone posted with what I learn...

    -Anthony

    Friday, May 24, 2013 1:02 PM
  • This is an excellent bit of coding Old Basic Coder - well done!
    Friday, May 24, 2013 5:10 PM
    Moderator
  • Hi Anthony,

    To implement sprites, you'd have to include some sort of depth buffer or calculation, to determine if part of the sprite was behind a vertical wall stripe or not (and not draw that section of the sprite if it shouldn't be visible). And you'd have to do some scaling of the sprites too to cater for perspective. But if you do manage to achieve that, it would be fantastic!

    I toyed with some very simple wall textures last night, based on a simple 8 x 8 bitmap. I was trying to see if I could map doors, windows or symbols...etc onto specific walk blocks. Eventually got this working, but it was so slow as to make it almost unplayable, even with only one or two visible blocks mapped.

    Good luck.


    Friday, May 24, 2013 5:47 PM
  • Nice program, I'd like to try adding smooth motion.
    Saturday, May 25, 2013 5:09 AM
  • Hi Anthony,

    To implement sprites, you'd have to include some sort of depth buffer or calculation, to determine if part of the sprite was behind a vertical wall stripe or not (and not draw that section of the sprite if it shouldn't be visible). And you'd have to do some scaling of the sprites too to cater for perspective. But if you do manage to achieve that, it would be fantastic!

    I toyed with some very simple wall textures last night, based on a simple 8 x 8 bitmap. I was trying to see if I could map doors, windows or symbols...etc onto specific walk blocks. Eventually got this working, but it was so slow as to make it almost unplayable, even with only one or two visible blocks mapped.

    Good luck.


    Is it possible to fake doors with black sections?

    Thanks for making this great program!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Monday, May 27, 2013 6:37 AM
    Owner
  • This is a really interesting program and challenge! I had no idea that a program like this could even be created in Small Basic. Amazing!

    I see that the "world" is implemented as a 2D array. I would like to play with this over the weekend and see what I can contribute. Maybe I can adapt my Obstacle Avoidance/Maze Traversal routine from Chomper (Pacman), which I designed for use with a 2D array. This would allow any enemy sprites to move about the game world in the background. It's worth a try.

    I'll everyone posted with what I learn...

    -Anthony


    Great, Anthony! Let us know what you come up with! Thanks!

    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Monday, May 27, 2013 6:38 AM
    Owner
  • Nice program, I'd like to try adding smooth motion.

    That would be another great thing to experiment with!

    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Monday, May 27, 2013 6:39 AM
    Owner
  • I'd just like say thanks to Old Basic Coder for writing and sharing this and to Ed for drawing attention to it. Whilst it's way beyond my skill level I'm already learning stuff from it.

    Like, at just a glance, I'm riveted by that Goto loop pause below the main sub calls and arrow key events. Never seen that before. Hope it stays sticky for a long time or at least till another sample as good as this comes along so we beginners can learn some excellent tips.

    I've already got questions on this code for later for another thread. Generous and helpful.


    You have to have a dream so you can get up in the morning. - Billy Wilder


    Monday, May 27, 2013 8:05 AM
    Moderator
  • Ed, 

    Currently, black is used as the draw colour if the wall is beyond a certain draw distance and for the floor and sky. The further away the wall, the more the colour shade fades towards black. BUT, the calculations could be changed so that the colours faded to white or grey instead, so it would give a "fog" effect. The sky and floor would also need to be drawn in the same white/grey colour too. But that would then free up black to be used as either doors or the maze exit. :-) 

    Steve

    Monday, May 27, 2013 8:50 AM
  • Ed, 

    Currently, black is used as the draw colour if the wall is beyond a certain draw distance and for the floor and sky. The further away the wall, the more the colour shade fades towards black. BUT, the calculations could be changed so that the colours faded to white or grey instead, so it would give a "fog" effect. The sky and floor would also need to be drawn in the same white/grey colour too. But that would then free up black to be used as either doors or the maze exit. :-) 

    Steve

    That would be good. If black was the maze exit, then a timer could be incorporated to make it more game like.

    Thoughts?


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Monday, May 27, 2013 10:44 PM
    Owner
  • Right then...

    After spending some time trying to get simple textures to work (so I could draw doors, windows, bricks, stone blocks etc) on the walls using a very simple 8x8 bit texture, I realised that SmallBasic still wasn't going to be fast enough. For each vertical line currently drawn for each wall segment, it would have to draw 8, hence the major slow down.

    Updates in the new version:-

    1) Included VERY simple textures (height of 1 and width of 60) with little slow down. There is even a "door" texture now present. The texture colours also fade to black. :-)

    2) Changed the viewing angle, so that the player's view is higher.

    3) Optimised the code in a number of place.

    NB. There is a variable called "size" within the code, which determines the width of the of the vertical lines drawn. In the updated version I have changed this to a value of "6". Any lower, then the maze runs too slow online, any higher, and it's harder to see the "textures" properly. If running offline then change this to either 1,2 or 4, depending on the speed of your PC. Mine seems to cope OK with a value of 4. (odd numbers above 1 cause some drawing issues!)

    Good luck to everyone else also looking to add extras to the maze code.

    Thanks,

    Wednesday, May 29, 2013 2:36 PM
  • new uploaded version is at program code :- WZN127
    Wednesday, May 29, 2013 2:36 PM
  • I updated the top of this thread with the new version. Does someone else want to take a pass at more game-like qualities?

    Things to add:

    • Open doors.
    • End of the maze. (Find the way out.)
    • Time limit.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Friday, May 31, 2013 12:39 AM
    Owner
  • I had originally thought that detailed textures would be too difficult to implement within small basic, without having to use extensions. However, after some experimentation, I now have this working locally. Still need to load the textures onto flickr so that this can run online. :-) 

    Please see the YouTube demo I have uploaded.....

    https://www.youtube.com/watch?v=DF196s0obUw&feature=youtube_gdata_player


    • Edited by Old Basic Coder Friday, June 28, 2013 7:51 PM highlighted youtube link
    Wednesday, June 26, 2013 8:40 PM
  • Impressive - can you share the code/textures?
    Wednesday, June 26, 2013 9:18 PM
    Moderator
  • Litdev,

    Thanks for the feedback.

    Copy of the updated code(including the texture processing) is below....

    ' Raycaster maze
    '
    'NB this will NOT run online. Textures are stored locally.
    ' I will, at some point, upload the textures onto Flickr, to
    'allow this to be run online
    '
    'optimisations for future versions.....
    '1) Square root calculations
    'determine if pre-calculating the square roots and storing the results in an array
    'is quicker than calculating them on the fly.
    'also look to amend the code so that the square roots are only changed (or referenced) when turning
    'as the square root calculations DO NOT change when moving forwards or backwards.
    'this should speed up the drawing when moving in a straight forwards.
    '2) Texture sizes
    'experiment with smaller texture sizes to see if 
    
    
    InitialSetUp:
    'w = 511
    'h = 384
    w = 399
    h = w/1.33
    size = 4
    'intensity = 70
    intensity = 120
    GraphicsWindow.Width = w
    GraphicsWindow.Height = h
    GraphicsWindow.CanResize = 1
    GraphicsWindow.BackgroundColor = "black"
    GraphicsWindow.PenWidth = size
    posX = 2.5
    posY = 10.5
    dirX = 1
    dirY = 0
    planeX = 0
    planeY = 0.66
    completed = 1
    moveSpeed = 0.2
    rotSpeed = 0.07
    CosrotspeedL = Math.Cos(-1 * rotspeed)
    SinrotspeedL = Math.Sin(-1 * rotspeed)
    CosrotspeedR = Math.Cos(rotspeed)
    SinrotspeedR = Math.Sin(rotspeed)      
    
    coladj = 255
    
    texWidth = 255
    texHeight = 3
    
    ' set up the key press interrupts  
    GraphicsWindow.Keydown = OnKeydown
    GraphicsWindow.Keyup = OnKeyup  
    
    ' call the setupmap subroutine to draw the initial map view
    setupmap()
    setuptexture()
    setupcolours()
    main()
    
    Loop:
    Goto loop
    
    Sub draw
      GraphicsWindow.DrawLine (x * size,drawStart,x * size,drawEnd)
    EndSub
    
    Sub drawfill
      GraphicsWindow.PenColor = "black"
      GraphicsWindow.DrawLine (x * size,0,x*size,drawstart)
      GraphicsWindow.PenColor = "black"
      GraphicsWindow.DrawLine (x * size,drawend,x*size,h)
    EndSub
      
    Sub nodraw
      GraphicsWindow.PenColor = "black"
      GraphicsWindow.DrawLine (x * size,0,x * size,h)
    EndSub
    
    sub main
      completed = 0
      starttime = Clock.ElapsedMilliseconds
      For x = 0 To w / size                       ' calculate ray position and direction 
        cameraX = 2 * x / (w / size) - 1            ' x-coordinate in camera space
        rayPosX = posX
        rayPosY = posY
        rayDirX = dirX + planeX * cameraX
        rayDirY = dirY + planeY * cameraX
        '
        'which box of the map we're in  
        mapX = Math.Floor(rayPosX)
        mapY = Math.Floor(rayPosY)
           
    ' length of ray from current position to next x or y-side
        sideDistX = 0
        sideDistY = 0
     
    ' length of ray from one x or y-side to next x or y-side
        deltaDistX = Math.SquareRoot(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX))
        deltaDistY = Math.SquareRoot(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY))
        'TextWindow.WriteLine ("x = " + x + " raydirx " + raydirx + " " + "raydiry " + raydiry)
        perpWallDist = 0
       
      'what direction to step in x or y-direction (either +1 or -1)
        stepX = 0
        stepY = 0
        hit = 0                       ' was there a wall hit?
        side = 0                      ' was a NS or a EW wall hit?
    
      ' calculate step and initial sideDist
        If rayDirX < 0 Then
          stepX = -1
          sideDistX = (rayPosX - mapX) * deltaDistX
        Else
          stepX = 1
          sideDistX = (mapX + 1.0 - rayPosX) * deltaDistX
        EndIf
        If rayDirY < 0 then
          stepY = -1
          sideDistY = (rayPosY - mapY) * deltaDistY
        Else
          stepY = 1
          sideDistY = (mapY + 1.0 - rayPosY) * deltaDistY
        EndIf
          
    ' perform DDA
    ' trace a "ray" until it hits a wall, and determine if it's an "X" (horizontal) or "Y" (vertical) wall      
        While hit = 0                          ' jump to next map square, OR in x-direction, OR in y-direction
          If sideDistX < sideDistY Then
            sideDistX = sideDistX + deltaDistX
            mapX = mapx + stepX
            side = 0 
          Else
            sideDistY = sideDistY + deltaDistY
            mapY = mapy + stepY
            side = 1
          EndIf
             
       ' Check if ray has hit a wall
          If worldMap[mapX][mapY] > 0 Then
            hit = 1
          EndIf
        EndWhile
      
      ' Calculate distance projected on camera direction.
        If side = 0 Then
          perpWallDist = Math.Abs((mapX - rayPosX + (1 - stepX) / 2) / rayDirX)
        Else
          perpWallDist = Math.Abs((mapY - rayPosY + (1 - stepY) / 2) / rayDirY)
        EndIf
          ' Calculate height of line to draw on screen
          lineHeight = Math.Abs(h / perpWallDist)
          lineHeight = Math.Round (lineheight)
          drawStart = (lineHeight * -1) / 2 + h / 2
          drawEnd = lineHeight / 2 + h / 2
    
          blockcolour = worldMap[mapx][mapY]
          colours()
                     
          If worldMap[mapx][mapy] < 6 Then
            draw()
            drawfill()
            
            Goto jumpend
          Else
              wallX = 0
              If side = 1 Then
                wallX = rayPosX + ((mapY - rayPosY + (1 - stepy) / 2) / rayDirY) * rayDirX
              Else
                wallX = rayPosY + ((mapX - rayPosX + (1 - stepX) / 2) / rayDirX) * rayDirY
              EndIf
              '!!! 256 x 256 pixel textures !!!
              wallX = wallX - math.floor(wallX)
              texX = math.Floor(wallX * texWidth)
              GraphicsWindow.DrawResizedImage(texture[texX],x*size,drawstart,size,drawEnd - drawStart)
              drawfill()
              
          EndIf
          GraphicsWindow.BrushColor = "black"
          GraphicsWindow.FillRectangle(1,h,w,50)
          GraphicsWindow.FillRectangle(w-5,0,20,h+20)
    
          
    jumpend: 
    
     
      EndFor
      completed = 1
      
    Endsub
    
    Sub colours
      coldistr = colourtable[blockcolour][1] * coladj
      coldistg = colourtable[blockcolour][2] * coladj
      coldistb = colourtable[blockcolour][3] * coladj
      colour = GraphicsWindow.GetColorFromRGB(coldistr, coldistg, coldistb)
      If side = 1 Then
        colour = GraphicsWindow.GetColorFromRGB(coldistr / 1.3, coldistg / 1.3, coldistb / 1.3)
      EndIf
      GraphicsWindow.PenColor = colour
    EndSub
    
    Sub onkeydown
      If completed = 1 Then                 'ensures that will not try to draw, when previous frame is still drawing
        keypress = GraphicsWindow.LastKey
        moveX = dirX * movespeed
        moveY = dirY * movespeed
    ' checks that nothing is in front then moves forward
        If keypress = "Up" Then
          If worldMap[Math.Floor(posX + moveX )][Math.Floor(posy)] = 0 Then
            posX = posX + moveX
          Endif
          If worldMap[Math.Floor(posx)][math.Floor(posY + moveY)] = 0 Then
            posY = posY + moveY
          Endif
        Endif
    ' checks that nothing is in behind then moves backwards    
        If keypress = "Down" Then
          If worldMap[Math.Floor(posX - moveX)][Math.Floor(posy)] = 0 Then
            posX = posX - moveX
          Endif
          If worldMap[Math.Floor(posx)][math.Floor(posY - moveY)] = 0 Then
            posY = posY - moveY
          Endif
        Endif
    ' rotate the view anticlockwise if turning left
        If keypress = "Left" Then
          oldDirx = dirX
          dirX = dirX * CosrotspeedL - dirY * SinrotspeedL
          dirY = oldDirX * SinrotspeedL + dirY * CosrotspeedL
          oldPlanex = planeX
          planeX = planeX * CosrotspeedL - planeY * SinrotspeedL  
          planeY = oldPlaneX * SinrotspeedL + planeY * CosrotspeedL
        EndIf
    ' rotate the view clockwise if turning right
        If keypress = "Right" Then
          oldDirx = dirX
          dirX = dirX * CosrotspeedR - dirY * SinrotspeedR
          dirY = oldDirX * SinrotspeedR + dirY * CosrotspeedR
          oldPlaneX = planeX
          planeX = planeX * CosrotspeedR - planeY * SinrotspeedR
          planeY = oldPlaneX * SinrotspeedR + planeY * CosrotspeedR
        EndIf
        'call main subroutine to draw the new frame/view
        main()
      EndIf
    EndSub
    
    Sub OnKeyUp
      keypress = ""
    EndSub
      
    Sub setupmap
    mapwidth = 21
    mapheight = 21
      'define the map in the mapline array as strings
      mapline[1] =  "178988811111111555555"
      mapline[2] =  "600000000000000000005"
      mapline[3] =  "600000002000005000051"
      mapline[4] =  "600000000000305000051"
      mapline[5] =  "600000002600305022201"
      mapline[6] =  "608080006000005000001"
      mapline[7] =  "606066006016604444441"
      mapline[8] =  "600000000010004000001"
      mapline[9] =  "606660000010004000001"
      mapline[10] = "800000000000007000003"
      mapline[11] = "800002200022000000003"
      mapline[12] = "800000000000000000033"
      mapline[13] = "800002200022000333033"
      mapline[14] = "800000000000000033031"
      mapline[15] = "803333311111111011011"
      mapline[16] = "800000011110000000002"
      mapline[17] = "800000001110000000002"
      mapline[18] = "800200000110000000002"
      mapline[19] = "800000000116543211302"
      mapline[20] = "800000000000000000003"
      mapline[21] = "811111111116543211222"
      
      ' 
      ' define some parameters that state how big the map is
      mapsizex = Text.GetLength (mapline[1])
      mapsizey = array.GetItemCount (mapline)
      '
      'try to read this in and convert it into a two dimensional array
      For yloop = 1 To mapsizey
        For xloop = 1 To mapsizex
          worldmap[xloop][yloop] = Text.GetSubText(mapline[yloop],xloop,1)
        EndFor
      EndFor
    EndSub
    
    Sub setuptexture
      path = "E:\Small Basic Projects\stone\stone"
      For f = 1 To 255
        path1 = Text.Append(path,f)
        path1 = Text.Append(path1,".jpg")
        texture[f] = imagelist.LoadImage(path1)
      EndFor
    '  path = "E:\Small Basic Projects\converted textures\wallbase"
    '  For f = 1 To 255
    '    path1 = Text.Append(path,f)
    '    path1 = Text.Append(path1,".jpg")
    '    texture[f] = imagelist.LoadImage(path1)
    '  EndFor
    EndSub
    
    
    Sub setupcolours
      'black
      colourtable [0][1] = 0
      colourtable [0][2] = 0
      colourtable [0][3] = 0
      'white/gray
      colourtable [1][1] = .75
      colourtable [1][2] = .75
      colourtable [1][3] = .75
      'red
      colourtable [2][1] = 1
      colourtable [2][2] = 0
      colourtable [2][3] = 0
      'green
      colourtable [3][1] = 0
      colourtable [3][2] = 1
      colourtable [3][3] = 0
      'blue
      colourtable [4][1] = 0
      colourtable [4][2] = 0
      colourtable [4][3] = 1
      'brown
      colourtable [5][1] = .66
      colourtable [5][2] = .33
      colourtable [5][3] = .16
      'dark brown
      colourtable [6][1] = .33
      colourtable [6][2] = .22
      colourtable [6][3] = .11
      'mid gray
      colourtable [7][1] = .37
      colourtable [7][2] = .37
      colourtable [7][3] = .37
      'dark gray
      colourtable [8][1] = .18
      colourtable [8][2] = .18
      colourtable [8][3] = .18
    EndSub

    The textures are actually generated from a small program I wrote on my Nexus 7 using RFO Basic!

    This takes a 256 x 256 pixel texture, and splits it into 256 x 1 pixel wide jpg images. These 1 pixel wide stripes are then used to draw each section of wall block, and are re-sized dynamically when they are drawn...

              '!!! 256 x 256 pixel textures !!!
              wallX = wallX - math.floor(wallX)
              texX = math.Floor(wallX * texWidth)
              GraphicsWindow.DrawResizedImage(texture[texX],x*size,drawstart,size,drawEnd - drawStart)

    Thanks,

    Friday, June 28, 2013 7:45 PM
  • I see, I sort of assumed you must be using lots of sub images, but was impressed how smooth it ran.

    Thanks for sharing.

    Friday, June 28, 2013 7:49 PM
    Moderator
  • Copy of texture splitting/creating code below, from my Nexus 7.....

    !convert bitmap into vertical stripes
    !load image from standard directory
    !split into vertical stripes of 1 pixel wide
    !create a new dynamic filename appended with the
    !stripe number
    !crop the image and save each stripe back
    GR.OPEN 255, 255, 255, 255
    GR.ORIENTATION 0  % Force landscape
    GR.SCREEN w, h
    GR.COLOR 255,255,0,0,1
    GR.SET.ANTIALIAS 0
    GR.SET.STROKE 0
    GR.BITMAP.LOAD image,"wallbase.jpg"
    GR.BITMAP.SIZE image,width,height
    PRINT width,height
    file1$ = "textures/wallbase"
    FOR x = 1 TO width-1
     file2$ = STR$(x)
     filename$ = file1$ + file2$
     l = LEN(filename$)
     filename$ = LEFT$(filename$,l-2) + ".jpg"
     GR.BITMAP.CROP temp,image,x,0,1,height
     gr.bitmap.save temp,filename$ 
     PRINT filename$
    NEXT

    Friday, June 28, 2013 7:49 PM
  • An earlier version (v0.6) using very simple 30 x 3 pixel images created within the code....

    http://smallbasic.com/program/?VGK960

    It runs a little bit smoother offline on my PC (quad core) than online.

    There is noticeable lag when trying to draw these simple textured walls vs plane coloured walls.

    I found that DrawResizeImage worked slightly better than just drawing multiple vertical lines, and allows for much more detailed textures.

    Friday, June 28, 2013 8:21 PM
  • It's this kind of imaginative 'pushing the limits' to see what can be achieved with simple methods that is lacking in much teaching of programming. 

    Rather than learning multiple languages, complex constructs, thousands of commands and libraries, the fun is being creative with a small (or at least well understood) language.  Programming is not a memory test, its about creativity.

    It is also this creativeness that will develop real skill and the best programmers of the future.

    Friday, June 28, 2013 8:37 PM
    Moderator
  • It appears that this thread supports a claim I make in an article i'm trying to finish:

    "Talk to other programmers

    ....Participate in a forum on your language. For Small Basic programmers the Small Basic forum, SB blog and TechNet wiki’s on MSDN are a fantastic resource. It will keep you up to date with what’s happening with the language and expose you to the best programs being written with that language. "

    Old Basic Coder, I got your reply in the other thread. Thanks for that.


    Friday, June 28, 2013 9:23 PM
    Moderator
  • re: ld's comment: "It is also this creativeness that will develop real skill and the best programmers of the future."

    One of the coolest comments so far I reckon... very helpful.

    I did a couple of years as a creative contributor for a whacky surf magazine and found innovation to be a lot of fun as well. The 2 are symbiotic. "Ask yourself what's missing? What aren't people creating that I want or need?" And if they don't need something, then give them something (good) and explain to them why someone else thinks it's cool.

    (talent driven demand) - I really could do with an auto fill fridge and a virtual environment that surrounds me everywhere I go, pls, sometime this decade would be nice. Some young people have even predicted that money, not cash, will no longer be a medium of exchange. I'll bet money on that.


    Friday, June 28, 2013 11:04 PM
    Moderator