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. General Programming
  3. C#
  4. Game Creation

Game Creation

Scheduled Pinned Locked Moved C#
questioncssgraphicsgame-devhelp
7 Posts 3 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.
  • S Offline
    S Offline
    SRJ92
    wrote on last edited by
    #1

    Hello, i am creating a platformer with a scrolling grid, a bit like Mario ... I have my grid set up in an int of 10 by 100..... now there are onyl 13 squares displayed on the screen at one time in a 640 by 480 box .. this is stored in a struct and added as so : Grid.Grid = new int[GridWidth, GridHeight]; I am using _Paint to put my graphics onto the screen I have already set up this following code to scroll a background for the game when the player reaches a certain position

         if (Player.Location.X >= 13)
            {
                XOffset += 4;
                if (XOffset > bgnd.Width - this.Width)
                {
                    XOffset = bgnd.Width - this.Width;
                }
            }
            else
            {
                Player.Location.X += 1;
    
            }
        }
    

    so i have some idea of what goes on , but i am stuck :O so, my question is this ..... How do i make the Grid scroll?

    L 1 Reply Last reply
    0
    • S SRJ92

      Hello, i am creating a platformer with a scrolling grid, a bit like Mario ... I have my grid set up in an int of 10 by 100..... now there are onyl 13 squares displayed on the screen at one time in a 640 by 480 box .. this is stored in a struct and added as so : Grid.Grid = new int[GridWidth, GridHeight]; I am using _Paint to put my graphics onto the screen I have already set up this following code to scroll a background for the game when the player reaches a certain position

           if (Player.Location.X >= 13)
              {
                  XOffset += 4;
                  if (XOffset > bgnd.Width - this.Width)
                  {
                      XOffset = bgnd.Width - this.Width;
                  }
              }
              else
              {
                  Player.Location.X += 1;
      
              }
          }
      

      so i have some idea of what goes on , but i am stuck :O so, my question is this ..... How do i make the Grid scroll?

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

      Hi, I'm not sure what it is you want, not even what platform you are using: DirectX, XNA, WinForms, ...? If it is WinForms, you might want and read this little article[^]. FYI: There are quite a number of articles about games here on CodeProject. :)

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

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      S 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, I'm not sure what it is you want, not even what platform you are using: DirectX, XNA, WinForms, ...? If it is WinForms, you might want and read this little article[^]. FYI: There are quite a number of articles about games here on CodeProject. :)

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

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        S Offline
        S Offline
        SRJ92
        wrote on last edited by
        #3

        ok sorry, erm... what i want is to scrool the grid as the player moves from the right to the left so that the player can proceed through the level and it isn't all displayed at once i am using winforms to make my game

        L 1 Reply Last reply
        0
        • S SRJ92

          ok sorry, erm... what i want is to scrool the grid as the player moves from the right to the left so that the player can proceed through the level and it isn't all displayed at once i am using winforms to make my game

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

          OK, read the article I provided a link to. Then whenever the grid has to move (by user action or timer), change your relevant data values and call Invalidate to get everything repainted. If everything is linked to a grid, and only part of that is visible, have a Location variable (i.e. a Point with X and Y) that holds the distance from your grid's top left corner to your visible area's top left corner, and offset everything inside your Paint handler by that distance. Graphics.TranslateTransform() could do all that for you. BTW: if you haven't already, I suggest you make your painting area double-buffered to reduce or avoid flicker. :)

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

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          S 1 Reply Last reply
          0
          • L Luc Pattyn

            OK, read the article I provided a link to. Then whenever the grid has to move (by user action or timer), change your relevant data values and call Invalidate to get everything repainted. If everything is linked to a grid, and only part of that is visible, have a Location variable (i.e. a Point with X and Y) that holds the distance from your grid's top left corner to your visible area's top left corner, and offset everything inside your Paint handler by that distance. Graphics.TranslateTransform() could do all that for you. BTW: if you haven't already, I suggest you make your painting area double-buffered to reduce or avoid flicker. :)

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

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            S Offline
            S Offline
            SRJ92
            wrote on last edited by
            #5

            ok, thanks

            P 1 Reply Last reply
            0
            • S SRJ92

              ok, thanks

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              Please don't delete your questions. Now it's impossible to follow the context of this question, and it could have been something useful to others. You've been a poster long enough to know that you shouldn't be doing this.

              I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

              Forgive your enemies - it messes with their heads

              My blog | My articles | MoXAML PowerToys | Onyx

              L 1 Reply Last reply
              0
              • P Pete OHanlon

                Please don't delete your questions. Now it's impossible to follow the context of this question, and it could have been something useful to others. You've been a poster long enough to know that you shouldn't be doing this.

                I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

                Forgive your enemies - it messes with their heads

                My blog | My articles | MoXAML PowerToys | Onyx

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

                Yes, there already is another guy asking basically the same thing, it is a bit harder now to convince him the subject got handled here. :)

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

                Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                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