Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Beginner's Shame: Manually Draw Characters

Beginner's Shame: Manually Draw Characters

Scheduled Pinned Locked Moved The Weird and The Wonderful
comgame-devlearning
11 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #1

    Back in my first year of programming, I was in a Visual Basic class, but I didn't like Visual Basic so I spent a good amount of my time coding in QuickBasic 4.5. In my infinite wisdom, I decided that it would be easier to use draw commands to show text on the screen rather than loading a font from the file system. So I created a function that took the top left coordinate of where to draw the string and it would draw the string... with Quick Basic draw commands. As I recall, there was a for loop to split the strings into individual characters. Then, there was a giant switch command on those characters (or was it a chained if statement... hmmm) to decide which draw commands to use. I then fine-tuned each letter so that large groups of pixels would be drawn as rectangles and individual pixels would be drawn with the command to set a single pixel. I was very impressed with my code, which I'm pretty sure was over 400 lines long! You can see it in action in my Tetris game at the link below, which also used only procedurally drawn textures (i.e., no image files were loaded): Tetris (scroll to bottom of page) I will see if I can find this chunk of code, so that you can be mesmerized by this astounding masterpiece. :-O

    [Forum Guidelines]

    J L B S 4 Replies Last reply
    0
    • A AspDotNetDev

      Back in my first year of programming, I was in a Visual Basic class, but I didn't like Visual Basic so I spent a good amount of my time coding in QuickBasic 4.5. In my infinite wisdom, I decided that it would be easier to use draw commands to show text on the screen rather than loading a font from the file system. So I created a function that took the top left coordinate of where to draw the string and it would draw the string... with Quick Basic draw commands. As I recall, there was a for loop to split the strings into individual characters. Then, there was a giant switch command on those characters (or was it a chained if statement... hmmm) to decide which draw commands to use. I then fine-tuned each letter so that large groups of pixels would be drawn as rectangles and individual pixels would be drawn with the command to set a single pixel. I was very impressed with my code, which I'm pretty sure was over 400 lines long! You can see it in action in my Tetris game at the link below, which also used only procedurally drawn textures (i.e., no image files were loaded): Tetris (scroll to bottom of page) I will see if I can find this chunk of code, so that you can be mesmerized by this astounding masterpiece. :-O

      [Forum Guidelines]

      J Offline
      J Offline
      josda1000
      wrote on last edited by
      #2

      I don't think I understand how this is a coding horror... I see this as a great learning experience. The more you learn the under-the-hood stuff, the better

      Josh Davis
      This is what plays in my head when I finish projects.

      A D 2 Replies Last reply
      0
      • J josda1000

        I don't think I understand how this is a coding horror... I see this as a great learning experience. The more you learn the under-the-hood stuff, the better

        Josh Davis
        This is what plays in my head when I finish projects.

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #3

        Every coding horror might be considered a learning experience (assuming you learn from it). In this case, I think I learned patience. Doesn't make it any less horrific. :)

        [Forum Guidelines]

        1 Reply Last reply
        0
        • A AspDotNetDev

          Back in my first year of programming, I was in a Visual Basic class, but I didn't like Visual Basic so I spent a good amount of my time coding in QuickBasic 4.5. In my infinite wisdom, I decided that it would be easier to use draw commands to show text on the screen rather than loading a font from the file system. So I created a function that took the top left coordinate of where to draw the string and it would draw the string... with Quick Basic draw commands. As I recall, there was a for loop to split the strings into individual characters. Then, there was a giant switch command on those characters (or was it a chained if statement... hmmm) to decide which draw commands to use. I then fine-tuned each letter so that large groups of pixels would be drawn as rectangles and individual pixels would be drawn with the command to set a single pixel. I was very impressed with my code, which I'm pretty sure was over 400 lines long! You can see it in action in my Tetris game at the link below, which also used only procedurally drawn textures (i.e., no image files were loaded): Tetris (scroll to bottom of page) I will see if I can find this chunk of code, so that you can be mesmerized by this astounding masterpiece. :-O

          [Forum Guidelines]

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          I did something similar long ago (around 1977): lots of measurements on electronic circuitry, getting automated using a PDP11 minicomputer (RSX11 operating system) and Fortran IV, and results plotted by an HP plotter lacking any (or any decent?) text output capability. So I did create a font, not as a giant switch statement, as a big table of strokes. The result was nice graphics (for that era at least) with labeled axes and legends. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          A 1 Reply Last reply
          0
          • L Luc Pattyn

            I did something similar long ago (around 1977): lots of measurements on electronic circuitry, getting automated using a PDP11 minicomputer (RSX11 operating system) and Fortran IV, and results plotted by an HP plotter lacking any (or any decent?) text output capability. So I did create a font, not as a giant switch statement, as a big table of strokes. The result was nice graphics (for that era at least) with labeled axes and legends. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            A Offline
            A Offline
            AspDotNetDev
            wrote on last edited by
            #5

            Luc Pattyn wrote:

            table of strokes

            Visited the massage parlor recently, eh? ;P Actually, I did something like that for my Cargobay game (listed on the same page as that Tetris game). I stored the game board as an array or something like that. I found that to be somewhat more reasonable than hardcoding the building of each game board.

            Luc Pattyn wrote:

            1977

            They had computers then? I wasn't born for another 8 years.

            [Forum Guidelines]

            L 1 Reply Last reply
            0
            • A AspDotNetDev

              Luc Pattyn wrote:

              table of strokes

              Visited the massage parlor recently, eh? ;P Actually, I did something like that for my Cargobay game (listed on the same page as that Tetris game). I stored the game board as an array or something like that. I found that to be somewhat more reasonable than hardcoding the building of each game board.

              Luc Pattyn wrote:

              1977

              They had computers then? I wasn't born for another 8 years.

              [Forum Guidelines]

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              aspdotnetdev wrote:

              They had computers then?

              yes, that was the computer era. It ended in the eighties, when they introduced "PC's", which weren't computers at all. They were a bit large; you could easily fit the content of your wardrobe in them without disturbing much; a 10MB (later 50MB) harddisk had the size of a modern dish washer. And that was more than enough to drive a pen plotter and more. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              B 1 Reply Last reply
              0
              • L Luc Pattyn

                aspdotnetdev wrote:

                They had computers then?

                yes, that was the computer era. It ended in the eighties, when they introduced "PC's", which weren't computers at all. They were a bit large; you could easily fit the content of your wardrobe in them without disturbing much; a 10MB (later 50MB) harddisk had the size of a modern dish washer. And that was more than enough to drive a pen plotter and more. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                B Offline
                B Offline
                Baconbutty
                wrote on last edited by
                #7

                Yup and if you wanted to use any Maths Libraries on a Prime Computer that I used, you had to grab the MathsLibrary, literally! It was something a similar size to a drum in a washing machine and you had to screw it into the top of the computer. It did have a disk/human interface to make it more interactive, yeah ok it was just a plastic handle but it was bloody heavy with all those disk platters inside.

                He took it all too far, but boy could he play guitar!

                1 Reply Last reply
                0
                • A AspDotNetDev

                  Back in my first year of programming, I was in a Visual Basic class, but I didn't like Visual Basic so I spent a good amount of my time coding in QuickBasic 4.5. In my infinite wisdom, I decided that it would be easier to use draw commands to show text on the screen rather than loading a font from the file system. So I created a function that took the top left coordinate of where to draw the string and it would draw the string... with Quick Basic draw commands. As I recall, there was a for loop to split the strings into individual characters. Then, there was a giant switch command on those characters (or was it a chained if statement... hmmm) to decide which draw commands to use. I then fine-tuned each letter so that large groups of pixels would be drawn as rectangles and individual pixels would be drawn with the command to set a single pixel. I was very impressed with my code, which I'm pretty sure was over 400 lines long! You can see it in action in my Tetris game at the link below, which also used only procedurally drawn textures (i.e., no image files were loaded): Tetris (scroll to bottom of page) I will see if I can find this chunk of code, so that you can be mesmerized by this astounding masterpiece. :-O

                  [Forum Guidelines]

                  B Offline
                  B Offline
                  BillW33
                  wrote on last edited by
                  #8

                  Sounds like you wrote some cool code. I suspect that it was a lot more work than simply using an available font. ;)

                  Just because the code works, it doesn't mean that it is good code.

                  1 Reply Last reply
                  0
                  • J josda1000

                    I don't think I understand how this is a coding horror... I see this as a great learning experience. The more you learn the under-the-hood stuff, the better

                    Josh Davis
                    This is what plays in my head when I finish projects.

                    D Offline
                    D Offline
                    Dave Calkins
                    wrote on last edited by
                    #9

                    I agree; not much of a horror. I think its pretty cool actually :) Not that I'd prefer to do it over using a font, but it looks like you did a pretty good job of procedurally rendered text.

                    1 Reply Last reply
                    0
                    • A AspDotNetDev

                      Back in my first year of programming, I was in a Visual Basic class, but I didn't like Visual Basic so I spent a good amount of my time coding in QuickBasic 4.5. In my infinite wisdom, I decided that it would be easier to use draw commands to show text on the screen rather than loading a font from the file system. So I created a function that took the top left coordinate of where to draw the string and it would draw the string... with Quick Basic draw commands. As I recall, there was a for loop to split the strings into individual characters. Then, there was a giant switch command on those characters (or was it a chained if statement... hmmm) to decide which draw commands to use. I then fine-tuned each letter so that large groups of pixels would be drawn as rectangles and individual pixels would be drawn with the command to set a single pixel. I was very impressed with my code, which I'm pretty sure was over 400 lines long! You can see it in action in my Tetris game at the link below, which also used only procedurally drawn textures (i.e., no image files were loaded): Tetris (scroll to bottom of page) I will see if I can find this chunk of code, so that you can be mesmerized by this astounding masterpiece. :-O

                      [Forum Guidelines]

                      S Offline
                      S Offline
                      Stefan_Lang
                      wrote on last edited by
                      #10

                      Hey, I don't see anything wrong with that. One of my first coding tasks at university was the other way round: a 'function plotter' that would take a function as input and 'draw' the graph on a text-only line printer using a 'resolution' of 132x66 characters (and using 'x' as pixels). I later adapted this little gem to print out a two-dimensional representation of a four-dimensional simplex (four dimensional equivalent of a three dimensional 'cube' if you will). Ok, it was a bit hard to actually 'see' anything, but it worked :) Now, if I still had the code (IIRC I let the stack of punch cards drop and eventually discarded them to save me the bother of sorting) I could try and combine it with yours to actually draw the 'x' characters that were meant to represent the pixels of what I wanted to draw. :D

                      A 1 Reply Last reply
                      0
                      • S Stefan_Lang

                        Hey, I don't see anything wrong with that. One of my first coding tasks at university was the other way round: a 'function plotter' that would take a function as input and 'draw' the graph on a text-only line printer using a 'resolution' of 132x66 characters (and using 'x' as pixels). I later adapted this little gem to print out a two-dimensional representation of a four-dimensional simplex (four dimensional equivalent of a three dimensional 'cube' if you will). Ok, it was a bit hard to actually 'see' anything, but it worked :) Now, if I still had the code (IIRC I let the stack of punch cards drop and eventually discarded them to save me the bother of sorting) I could try and combine it with yours to actually draw the 'x' characters that were meant to represent the pixels of what I wanted to draw. :D

                        A Offline
                        A Offline
                        AspDotNetDev
                        wrote on last edited by
                        #11

                        It is portable, I'll give it that. :laugh:

                        [Forum Guidelines]

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups