View previous topic - View next topic |
Author |
Message |
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Thu Feb 16, 2006 3:12 am Post subject: First test |
[quote] |
|
Ok, so this is the first test for maps. I couldnt' figure out why it wouldnt' consitently move when the WalkState was present (when holding a movement key), so I just did the scrolling via PauseState for now.
However, I'm not sure why it's so jerky. I know it's not my timer, because i changed the variables in the player class and still got the same effect. It's like it's misdrawing it one frame every second or so, which causes flicker.
I don't know, test out the .exe, look at the code, and tell me what you think. All the movement deals with the engine.cpp, player.cpp, map.cpp, and some input.cpp classes
It can be found
Thanks,
Jason
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Thu Feb 16, 2006 4:02 am Post subject: |
[quote] |
|
Can you run other programs from programs? LIke can I make a program and run it off another one? (like call it from the prog)
Thanks,
Jason
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Thu Feb 16, 2006 4:12 am Post subject: |
[quote] |
|
Yeah (otherwise, computers wouldn't be usable at all); while the Windows code is probably more arcane and nasty, the simple functionality within unix code is to fork and exec.
If you ever get into shell scripting --- with something like bash/sh scripts, or traipse around with perl --- you will probably end up doing this a lot. (Perl, and some other languages which have adopted the syntax, such as bash and PHP, supports a backtick construct, where the backticked text is executed in situ, returning the result (and script execution) to the caller after the other program exits.)
However saying, there may already be better alternatives to what you are attempting to do, either built into the language directly, or via a standard/third-party library. Is this a general information query, or do you have something explicitly in mind that you would like to do? _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Thu Feb 16, 2006 4:28 am Post subject: |
[quote] |
|
Ya. Since I'm not doing large continuous worlds anymore, I'm going to make huge ass bitmaps.
what I was thinking of doing was creating the bitmap through a program I made (that combines smaller images) at the start of the game/level/whatever. I could then unload the bitmaps as I grew out of them.
This would keep the file from getting to be too large (hundreds of megs) and I still could have 10-20 megs of map in memory at one time. The user also couldnt' mess with the maps because they're created at runtime, and this would allow for updates in the game (I could make another map and use it within the game)
The only problem with that would be items and such (vs. the tile method). I'd, what, have to set items and boundaries at fixed pixel locations. How could I check where the player was? (like to see if he'd run into a wall or something?) Using an idea from before, I could attempt to mask the area of boundary with a layer, but not blit it to the screen, and check for color.
I don'tk now, tell me what you think,
Jason
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Thu Feb 16, 2006 4:37 am Post subject: |
[quote] |
|
I mean, I don't know how else to do it. The scrolling looks terrible... try the demo I put up. It's all jerky and stuff.
When I first did it with the bitmap it was amazing, but soooo much memory. I just don't know what to do.
Jason
|
|
Back to top |
|
|
Ninkazu Demon Hunter
Joined: 08 Aug 2002 Posts: 945 Location: Location:
|
Posted: Thu Feb 16, 2006 5:19 am Post subject: |
[quote] |
|
You could stay calm and try to really grasp the concept before giving up and wasting time coding a very bad idea.
|
|
Back to top |
|
|
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Thu Feb 16, 2006 6:38 am Post subject: |
[quote] |
|
Ninkazu wrote: | You could stay calm and try to really grasp the concept before giving up and wasting time coding a very bad idea. |
Agreed. You've spent less than a week on this. That, in a project's lifetime, is very little even for a basic project. Don't plow through this, stop and understand what you're doing before launching yourself into the very first idea that comes to mind.
To be frank, it seems most of what you've done to date has been briefly skim an idea, attempt to implant it but only partly succeed because you haven't attempted to look up tutorials and documentation long enough, then post your source and ask us to find out what's wrong for you. There's absolutely nothing wrong with asking for help, but spending a few days experimenting with different algorithms and reading up on what you're doing beforehand is even better.
Rome wasn't built in a day dude, neither was anyone here's first per-pixel scrolling 2D map engine. ;) _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
Nephilim Mage
Joined: 20 Jun 2002 Posts: 414
|
Posted: Thu Feb 16, 2006 8:24 am Post subject: |
[quote] |
|
RuneLancer wrote: | Rome wasn't built in a day dude, neither was anyone here's first per-pixel scrolling 2D map engine. ;) |
Very true. I built my RPG in Director, which handles all the storage, loading, unloading, compositing, and blitting to the screen of all bitmap data for you transparently. Despite this, it still took me a good week to get my map engine working exactly the way I wanted it. And I was already very familiar with Director and had implemented several tile map engines in Director before that (and scrapped many more mid-experimentation).
Go slowly. Read up. Don't get discouraged.
Here are some resources for learning more about making tile-based games. Some are written specifically for Flash, but the concepts apply to any tile-based games.
http://www-cs-students.stanford.edu/~amitp/gameprog.html
http://www.tonypa.pri.ee/tbw/index.html
http://oos.moxiecode.com
http://www.strille.net/tutorials/part1_scrolling.php _________________ Visit the Sacraments web site to play the game and read articles about its development.
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Thu Feb 16, 2006 1:10 pm Post subject: |
[quote] |
|
Thanks nephilim. I'll look at them when I get home (I'm in school right now).
And I think everyone's right when they say to slow down.
What do you think about planning a design doc? I've never made one before because I never had the patience to sit and write one, but this might turn into a good idea.
The reason I'm saying this is because I found myself adding/removing functions constently, often disordering my project. I guess I just figured if I had everything planned, it'd work more smoothly.
But the question is, how do I know what goes with what? Do I want to attempt to shuve everything into some sort of class (like there's a map class, that handles a tile class (tiles have position, walking verification, etc.), which can be used in coherance with the player class, etc.)
I gues what I'm saying is: Is there a way to specifically determine if a class is needed, or is it all done by preference? I want my code as clean as possible, so I"ll do what it takes to make it that way.
Thanks again,
Jason
|
|
Back to top |
|
|
zenogais Slightly Deformed Faerie Princess
Joined: 10 Jan 2006 Posts: 34
|
Posted: Fri Feb 17, 2006 12:19 am Post subject: |
[quote] |
|
Gardon: The rules for whether or not a class is necessary or appropriate for a specific purpose are basic knowledge articles that come with learning the C++ language. Classes are not needed for everything, in fact for the map stuff it would probably cut down significantly on compile time and bloat if you didn't use classes (use struct's instead). There are no hard and fast rules for these things, but generally for map systems you'd use a struct over a class as they're cheaper when you need to create a lot of them, and they can be cast to a char * and written out and read back from a file, something classes often cannot do because of how their allocated memory space differs from that of a struct.
Generally when you're trying to solve a problem, see if there isn't a design pattern that would make it easier. For example, your system right now mixes model, control and occasionally view into the same classes. For instance you handle player movement in the class which polls for input, a system that can be inflexible. The model-view-controller pattern would certainly help clean this up. The biggest thing to do is research. I'm sure everyone here did a lot of documentation scouring and algorithm research during the course of developing their games. Not only is this the best way to learn about more efficient ways of doing things, but it's probably the best way to write the clean type of game engine you want.
Good Links To Get Started:
SDL Documentation Wiki
Wikipedia (Best place to learn about algorithms)
InformIT (Excellent website for learning about advanced C++ systems (template policy systems, design patterns etc...)
Last edited by zenogais on Fri Feb 17, 2006 3:08 am; edited 1 time in total
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Fri Feb 17, 2006 2:55 am Post subject: |
[quote] |
|
Thanks for the links.
what i was trying to do with multiple classes was make the code flow easier (like everything had its own class so it's all organized).
I just don't know where else to go for map handling, as I don't want to crowd engine.cpp
Thanks,
Jason
|
|
Back to top |
|
|
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Fri Feb 17, 2006 3:07 am Post subject: |
[quote] |
|
Using OOP is not a necessity for clean well-organized code. In fact, if you're not comfortable with it, you could end up making things worse! Improper use of OOP can seriously impact your game's performance and the readability of your code. So don't worry too much about bending over backwards to make use of OOP, especially if you find yourself spending more time trying to get a class to work than working on the engine itself. ;)
However, properly used, OOP can make things much easier to manage. It just takes experience; as you begin to get a feel for OOP, you'll know better how to deal with individual situations and the best way to approach a problem.
For map handling, you could look into singletons. A singleton is, basically, a class which can only be instantiated once. It's useful if you plan on representing a fundamental "chunk" of your engine through OOP; Endless Saga's resource management system is a singleton and I managed to design something so easy to use I don't even have to worry about how different parts of the game share resources anymore. It does the work on its own. :D _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Fri Feb 17, 2006 3:20 am Post subject: |
[quote] |
|
are "Effective C++" and "More Effective C++" god books to read up on? I mean, if I wanted to better my code?
i think the way I learned and the cross with java make my class oriented design strategies blossum.
I'm just trying to think if my game gets really big, how will I manage the code? Will I put it in classes and separate the files so I can read it easier, or make it more memory efficient by schrunching it all in one file?
I mean, how do you design a game so that it's easy to read and maintain?
Jason
|
|
Back to top |
|
|
zenogais Slightly Deformed Faerie Princess
Joined: 10 Jan 2006 Posts: 34
|
Posted: Fri Feb 17, 2006 3:28 am Post subject: |
[quote] |
|
"Effective C++" and "More Effective C++" are excellent books, however they're more about the correct usage of the core C++ language libraries, than about actual techniques for improving program design. Also, moving all your classes into one file saves absolutely no memory, and instead makes your game impossible to mantain. The size of an executable is not affected by how many files your program is split into.
As for the design bits, that's one of the hardest questions to answer. Really, I've only learned how to make a large program maintainable by writing lots and lots of large applications, and making bad organization mistakes which I decided to correct. A general rule of thumb I use is if I find myself repeating anything, I think about methods for reducing the amount of repetition (creating a function to do most of the repeated code, or creating a new class). Usually this not only makes your code fantastically more readable, but it saves your fingers from getting tired :P Also, again, look up design patterns, many many many of them can save you lines of code, and also increase the organization, flexibility, maintainability and aesthetic value of your code.
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Fri Feb 17, 2006 3:35 am Post subject: |
[quote] |
|
Ya, but what I mean is how exactly do you structure your projects? Lots of files, lots of classes, what?
I mean, would you really want hundreds of lines of code in the main function that runs your game loop?
Jason
|
|
Back to top |
|
|
|
Page 1 of 2 |
All times are GMT Goto page 1, 2 Next
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|