Game Creation
-
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 positionif (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?
-
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 positionif (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?
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.
-
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.
-
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
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.
-
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.
-
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
-
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
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.