Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - BurnEmDown

Pages: [1]
1
General / Re: Error regarding VertexArray
« on: January 22, 2019, 07:47:49 pm »
Thanks, it worked!! I've never used the debugger tool with visual studio before, so it was a little hard to understand what was going on, but then I found out that I did make a mistake in the main ZombieArena.cpp file, which I didn't notice before  ::), it was assigning arena.width = 500 twice instead of assigning it once and arena.height = 500 once  :o
Thanks again for all the help!  ;D

2
General / Re: Error regarding VertexArray
« on: January 21, 2019, 05:33:21 pm »
Thanks, I've tried what you suggested, and the application didn't exit without me pressing the escape key. The game loaded as usual, and as soon as I pressed any of the keys, only my character was visible on the screen, with a black background as before.

3
General / Re: Error regarding VertexArray
« on: January 21, 2019, 04:43:29 pm »
I believe the book's source code is publicly available, but only to packt's registered users (the registration is free). After you register, you can click on "Code files" here: https://www.packtpub.com/game-development/beginning-c-game-programming and download the files.
I've gone through it and everything I've written seems to be matching what they have in the source code files.
I'm not sure how can I test if the texture is loaded correctly. Would it be of any help if I upload all of my code files here?

4
General / Re: Error regarding VertexArray
« on: January 21, 2019, 11:32:49 am »
After checking the book's errata section, I saw that they've reported the error, and the fix is as follows:

It is:
// Create the backgroundVertexArray background;

Should be:
 // Create the background

VertexArray background;

After applying the necessary changes (and removing the no longer needed 'vertices' and 'states' variables), I manage to get a no-error code, but when I start the game, I still don't see any background, only a black screen with my character on it. I'm going to go through all of the code I've written so far and check if I've made any mistake.

5
General / Error regarding VertexArray
« on: January 20, 2019, 01:29:01 pm »
Hello everyone, I've recently started learning C++ game programming with a book called:
"Beginning C++ game programming", which uses SFML. I've followed the book's instructions and am currently in page 229, in the ZombieArena project.
For some reason, the code that they give in the book doesn't work. First, in page 221, they instruct to create a ZombieArena.h file which includes only these lines:
#pragma once
using namespace sf;
int createBackground(VertexArray& rVA, IntRect arena);
Then for the next few pages they instruct how to code the createBackground function in a 'CreateBackground.cpp' file.
After that, in page 227, they instruct to return to the main file, the ZombieArena.cpp file, and make use of the createBackground function, with these few lines, first at the top of the file:
// Create the backgroundVertexArray background;
// Load the texture for our background vertex array
Texture textureBackground;
textureBackground.loadFromFile("graphics/background_sheet.png");

And then inside the game loop:
// Pass the vertex array by reference
 // to the createBackground function
 int tileSize = createBackground(background, arena);
and:
// Draw the background
 window.draw(background, &textureBackground);

However, I'm received several errors:
First, they declare a Texture called textureBackground but try to use one called background, I've fixed this by changing background to textureBackground.
Then, in the header file, visual studio doesn't recognize VertexArray, I've fixed it by adding an #include statement for SFML/graphics.
Then, it seems that they suggest sending a Texture into the createBackground object, even though it accepts only a VertexArray reference. I've looked online a bit and following the example from here:
https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php
Found that I can eliminate the errors by adding these lines of code:
VertexArray vertices;
RenderStates states;
states.texture = &textureBackground;
After declaring the textureBackground Texture, and then calling createBackground like so:
int tileSize = createBackground(vertices, arena);
and window.draw like so:
window.draw(vertices, states);

However, after running the game, I still don't see any background, only the player. I can't figure out how to fix this issue, and the book doesn't help at all with it, nor can I find any useful information on the internet. Any help will be appreciated, thanks in advance!

Pages: [1]
anything