• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
superman3275

SFML Error! :(

15 posts in this topic

So, I'm getting this error:

[CODE]
10.0/vc/include/vector
Line: 932
Expression: Vector Subscript out of range
[/CODE]

Whenever I create a MainGame object(The code is below) I get this error.
I'm pretty sure I'm using constructors wrong or I'm doing something with vectors that's stupid, but I can't track down the error(Believe me I'm trying!).

[url="http://www.mediafire.com/?s6ntr1ky1ydbbue"]Download Code Here[/url]
0

Share this post


Link to post
Share on other sites
Your code's a little messy and confusing:

1) Your main.cpp doesn't seem to be your actual main.cpp, since it's just basically a HelloWorld

2) Your actual main.cpp seems to be BREAKOUT.cpp. And in that file, you instance an object of type GameMain and call it MainGame. Crikey, confusing much?

3) Your post indicates you are creating a MainGame object, but you are actually creating a GameMain object. (Unless BREAKOUT.cpp is not your actual main.cpp)

This kind of thing makes it hard to convince anyone to take a look at your code.

That being said, have you tried stepping through with the debugger? Knowing exactly which line triggers the exception, and what the current state values are, can go great lengths toward knowing what the problem is.
0

Share this post


Link to post
Share on other sites
Oh, and BREAKOUT.cpp is Main.cpp, in visual studio your "actual" main.cpp has your solutions name, Sorry for the misunderstanding :).
I should rename that! I'm not sure what I should name it too, I'll think about it.
Typo! Sorry!
0

Share this post


Link to post
Share on other sites
1) Again, if you're sharing you code, don't include things like the contents of the Debug/ directory in the archive.
2) It looks like the problem is in your GameDraw constructor, which tries to assign to elements of a vector that you didn't initialize.
3) Also, even if that did work, it would probably break later because you're passing a vector to that function by value, which makes a temporary copy, and then tries storing pointers to the elements of that temporary vector. When the constructor finishes running the temporary vector gets destroyed and you're left with pointers to destroyed objects.
0

Share this post


Link to post
Share on other sites
1) I forgot! Stupid me. I'll do that next time.
2) I figured as much, I'll try passing by reference.
3) Same as answer two, I'll pass by reference.

Thanks for the help, I'll update you if I fix it.
0

Share this post


Link to post
Share on other sites
Passing by reference won't fix number two, the vector you are [i]assigning to[/i] doesn't have any elements in it. You either need to initialize it in the member initializer list, resize() it before you start accessing it, push_back() the pointers you are storing, or something else that actually allocates members in the vector.
0

Share this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1350254649' post='4990175']
1) Again, if you're sharing you code, don't include things like the contents of the Debug/ directory in the archive.
[/quote]

To this point, I had to share a number of C++ projects in the past so [url="http://www.gamefromscratch.com/post/2011/08/25/Project-Cleaner.aspx"]I created a utility[/url] that cleaned them up shrinking them down. You may find it useful.
0

Share this post


Link to post
Share on other sites
So I fixed it doing everything you did, But now it says my image file is too large!
it says it's this (in format: amount of pixels width x amount of pixels height ): (300000000 pixels by 300000000 pixels) and it won't load the images! What?
0

Share this post


Link to post
Share on other sites
Does it actually say 3435973836 or 3452816845? Those would be the decimal values for 0xCCCCCCCC or 0xCDCDCDCD which are MSVC fill patterns for uninitialized memory. One is for uninitialized heap and the other for uninitialized stack. At a guess, you've run into the member variable constructor order problem, which happens when the compiler constructs member variables in order of their declaration in the class definition and not the order you specify in the member initialization list.
1

Share this post


Link to post
Share on other sites
Yes SiCrane, that's exactly the numbers! It says it is uninitialized by (3435973836 x 3435973836) two times, for two images. Can you elaborate on the member variable constructor order problem that you described :)?
0

Share this post


Link to post
Share on other sites
When an object is constructed, first any base classes are constructed, then its member variables are constructed in order of declaration in the class definition, regardless of what order you put them in the member initialization list. If you use one member variable to initialize another member variable in the member initialization list of a constructor you need to be sure that any member variable referenced actually appears above in the class definition. The easiest way to do this is to make sure that your member initialization list always follows the same order as the class definition and don't reference member variables that appear later. MSVC is unfortunately just about the only major compiler on the planet that won't give you a warning for not putting your member initialization list in class declaration order (which is frankly stupid).
0

Share this post


Link to post
Share on other sites
I did that, and now It shows the ball moving, you can't move your paddle, and none of the blocks are displayed. Well, I'm still trying to fix it :(.
0

Share this post


Link to post
Share on other sites
Okay, I'm not trying to fix it. I need to do something simpler. I do not have the knowledge required yet to make breakout. I am now going to attempt a space invaders clone, or maybe something of the sort. This project is dead, and the code design is stupid. I need to start preplanning, creating interfaces, and designing my classes better.
0

Share this post


Link to post
Share on other sites
Judging by your errors, the problem isn't that breakout is too complicated for you, the problem is that you're trying to tackle too much of the complexity all at once. Start in smaller chunks and grow slowly, testing as a you go. Don't try constructing a ball, paddle and bricks all at once. First put in the paddle, then maybe see about moving it around and then put in something else.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0