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. I have a few questions :)

I have a few questions :)

Scheduled Pinned Locked Moved C#
helpquestioncsharpgraphicsgame-dev
5 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.
  • R Offline
    R Offline
    Raztor0
    wrote on last edited by
    #1

    Firstly, I would like to say that I have tried Google-ing my problems but nothing really helps at all. Now let me introduce myself before asking you all my questions :P I'm 16 years old, and I have a culminating to complete for school. However, I do not need help with the actual code. Another thing you should know is I'm not that advanced with C# so I'll ask my question as best I can :) I am in the process of making a Tetris game in C#, and am running into a couple problems that I'd like to know if there is a solution to. So let's begin. First question: As I was getting the Tetris to work and it's coming together, I realized that I was re-drawing EVERYTHING each time something new happens. Is it possible to somehow tell C# to only redraw a specific part of the screen (the falling piece) rather than every other piece on the screen every time? Since those pieces won't be moving unless I complete a row, I really don't want to have to tell it to draw them every time. Also, I noticed if I don't tell it to draw, it won't draw them, and they won't appear. Which didn't solve my problem at all :( Second question: IF the above is not possible or anything like that, is there any way to tell the application to use more of the available RAM in the system? I'm asking this because, seeing as the Tetris program lags when there's many pieces on the board, it really does sound miraculous how popular games like Call of Duty don't lag on this computer. Thanks to everyone reading this and if anyone needs further clarification just post a comment and I'll try to answer :)

    S D R 3 Replies Last reply
    0
    • R Raztor0

      Firstly, I would like to say that I have tried Google-ing my problems but nothing really helps at all. Now let me introduce myself before asking you all my questions :P I'm 16 years old, and I have a culminating to complete for school. However, I do not need help with the actual code. Another thing you should know is I'm not that advanced with C# so I'll ask my question as best I can :) I am in the process of making a Tetris game in C#, and am running into a couple problems that I'd like to know if there is a solution to. So let's begin. First question: As I was getting the Tetris to work and it's coming together, I realized that I was re-drawing EVERYTHING each time something new happens. Is it possible to somehow tell C# to only redraw a specific part of the screen (the falling piece) rather than every other piece on the screen every time? Since those pieces won't be moving unless I complete a row, I really don't want to have to tell it to draw them every time. Also, I noticed if I don't tell it to draw, it won't draw them, and they won't appear. Which didn't solve my problem at all :( Second question: IF the above is not possible or anything like that, is there any way to tell the application to use more of the available RAM in the system? I'm asking this because, seeing as the Tetris program lags when there's many pieces on the board, it really does sound miraculous how popular games like Call of Duty don't lag on this computer. Thanks to everyone reading this and if anyone needs further clarification just post a comment and I'll try to answer :)

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      I assume you are using GDI+ to draw. try using double buffer. this.SetStyle(ControlStyles.DoubleBuffer, true); Instead to draw every command to screen, it draws to memory and when all completed, it draws already completed drawing from memory. Always use .Flush to clean graphic controls after usage. also you can use this.Invalidate(Rectange) to force update of specific region. Here are some articles about tetris: A .Net Tetris game in c# using GDI+[^] Falling Blocks Game[^]

      1 Reply Last reply
      0
      • R Raztor0

        Firstly, I would like to say that I have tried Google-ing my problems but nothing really helps at all. Now let me introduce myself before asking you all my questions :P I'm 16 years old, and I have a culminating to complete for school. However, I do not need help with the actual code. Another thing you should know is I'm not that advanced with C# so I'll ask my question as best I can :) I am in the process of making a Tetris game in C#, and am running into a couple problems that I'd like to know if there is a solution to. So let's begin. First question: As I was getting the Tetris to work and it's coming together, I realized that I was re-drawing EVERYTHING each time something new happens. Is it possible to somehow tell C# to only redraw a specific part of the screen (the falling piece) rather than every other piece on the screen every time? Since those pieces won't be moving unless I complete a row, I really don't want to have to tell it to draw them every time. Also, I noticed if I don't tell it to draw, it won't draw them, and they won't appear. Which didn't solve my problem at all :( Second question: IF the above is not possible or anything like that, is there any way to tell the application to use more of the available RAM in the system? I'm asking this because, seeing as the Tetris program lags when there's many pieces on the board, it really does sound miraculous how popular games like Call of Duty don't lag on this computer. Thanks to everyone reading this and if anyone needs further clarification just post a comment and I'll try to answer :)

        D Offline
        D Offline
        DiscoJimmy
        wrote on last edited by
        #3

        As the other guy said, I assume you're using GDI+. This is bad. GDI+ was not meant for games. Call of Duty certainly does not use GDI+. You need to go to microsoft's download site and download the XNA 3.1 game libraries. Don't worry about all the xbox stuff, you can write all the code in C# and it'll run on windows. You'll have to rewrite some of your drawing code, but if you organized it properly the game logic should all copy over as is. This will be 10x faster than using windows forms gdi stuff. FYI, this ALSO isn't what the call of duty folks are using, but it's a lot closer.

        1 Reply Last reply
        0
        • R Raztor0

          Firstly, I would like to say that I have tried Google-ing my problems but nothing really helps at all. Now let me introduce myself before asking you all my questions :P I'm 16 years old, and I have a culminating to complete for school. However, I do not need help with the actual code. Another thing you should know is I'm not that advanced with C# so I'll ask my question as best I can :) I am in the process of making a Tetris game in C#, and am running into a couple problems that I'd like to know if there is a solution to. So let's begin. First question: As I was getting the Tetris to work and it's coming together, I realized that I was re-drawing EVERYTHING each time something new happens. Is it possible to somehow tell C# to only redraw a specific part of the screen (the falling piece) rather than every other piece on the screen every time? Since those pieces won't be moving unless I complete a row, I really don't want to have to tell it to draw them every time. Also, I noticed if I don't tell it to draw, it won't draw them, and they won't appear. Which didn't solve my problem at all :( Second question: IF the above is not possible or anything like that, is there any way to tell the application to use more of the available RAM in the system? I'm asking this because, seeing as the Tetris program lags when there's many pieces on the board, it really does sound miraculous how popular games like Call of Duty don't lag on this computer. Thanks to everyone reading this and if anyone needs further clarification just post a comment and I'll try to answer :)

          R Offline
          R Offline
          Raztor0
          wrote on last edited by
          #4

          Ah, thanks to both of you that answered. That makes sence :) And alright, I'll try the invalidate(Rectangle) thing, I hope that works. And also, I'll download XNA and I'll play around with it. Thanks again guys.

          S 1 Reply Last reply
          0
          • R Raztor0

            Ah, thanks to both of you that answered. That makes sence :) And alright, I'll try the invalidate(Rectangle) thing, I hope that works. And also, I'll download XNA and I'll play around with it. Thanks again guys.

            S Offline
            S Offline
            Saksida Bojan
            wrote on last edited by
            #5

            If you want alternative to XNA, you can look at SlimDX. This framework was developed after microsoft decidec to stop developing Managed Direct X. I noticed of its exsistence, when I needed to install after i installed comercial game. Yes it is very popular and I wont say the name, because I do not want to advertise

            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