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 - bobojoeho

Pages: [1]
1
General / Re: How to make a list with a dynamic length?
« on: March 15, 2024, 07:17:37 pm »
ok thanks

i am new to c++ so i am just learning about arrays and stuff

2
General / How to make a list with a dynamic length?
« on: March 15, 2024, 12:11:23 am »
So I want to make a list that I can change the length of during my program.

Making an array requires me to set its length whenever I create the array, and that length is permanent.

Any ways to store a list of numbers, such that I can increase the length of the list or decrease it whenever I want?

3
General / Re: Can't change shape's attributes outside of int main()
« on: February 15, 2024, 01:09:33 am »
Ok....

So I did a little more testing and I think I know the problem.  Whenever I create a shape, I can do whatever I want with it as long as I am working in the same function that the shape was created in.

Up till now, I was creating shapes in int main, and trying to change them in other functions, or vice versa.

So you mentioned passing objects back and forth between functions.  If I create an object in int main, but pass it to another function, then I can work with it in that other function?  If so, then I have all the answers I need (until the next bug at least).

4
General / Re: Can't change shape's attributes outside of int main()
« on: February 14, 2024, 11:25:35 pm »
Ok sure.


Here is a script that does run for me:
_______________________________
#include <SFML/Graphics.hpp>

int main() {

sf::CircleShape shape(200);
shape.setFillColor(sf::Color(150, 150, 150));

}
_______________________________


A script that doesn't run would be:
_______________________________
#include <SFML/Graphics.hpp>

sf::CircleShape shape(200);

shape.setFillColor(sf::Color(150, 150, 150));  // this line here creates the error, apparently "this declaration
                                                                  //has no storage class or type specifier"
int main() {

shape.setPosition(sf::Vector2f(5, 5));

}
______________________________


As you can see, creating the object works fine, but trying to change its attributes causes an error.  This also happens when I am trying to change the attributes of a window.
If this helps at all, I can detect key presses just fine using SFML.

5
General / Re: Can't change shape's attributes outside of int main()
« on: February 14, 2024, 08:20:44 pm »
This problem occurs whether or not I create the shape inside of int main.  I am using only one file, and I include SFML at the very beginning.  I am just confused as some of SFML's commands work outside of int main, but not others.

I am trying to make a platformer, and I want a function that will create an object, by adding its attributes to a few arrays.  Later on in my script, I will create the shapes in the arrays and draw them.  This would allow me to store my object's positions so that I can detect collisions too.

6
General / Can't change shape's attributes outside of int main()
« on: February 13, 2024, 09:27:17 pm »
Hi guys its me again.  So I got SFML to work and everything, but I have an interesting issue.  Some certain SFML commands only work if they are placed inside the int main() function.  I can create shapes outside of the main loop, but whenever I try to change their size, or any other attribute, I get an error saying "this declaration has no storage class or type specifier".  So far, the commands that don't work are any command that modifies or sets attributes to my shapes or window.  I made sure that when I tried to change my shape's attributes I created the shape also outside the main loop and above my script so I wasn't changing a nonexistent shape.

Any ideas on how to fix this?  I think its kinda weird since I can create shapes wherever I want, but it appears I can only set their attributes inside int main().

7
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 05:02:42 am »
So the problem isn't with my bit sizes?  Since Visual Studio can work with both, and I have the lower bit version of SFML?

Well if that's true, then I still need to fix sfml-window-2.dll not being found.

The tutorial said if I am using the dynamic version (which I am), then I need to copy my DLL files "to the directory where your compiled executable is"

Apologies again for my lack of knowledge, I am pretty new to this.

8
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 03:27:14 am »
Ok so I changed my include paths and it still doesn't work.  The program will compile successfully with 0 errors, but my script (obtained from end of tutorial) doesn't work.  It will open up a window, but immediately give an error message saying that sfml-window-2.dll wasn't found.

As for the 32bit SFML not being compatible with 64bit VS, would you suggest running my VS in Win32 or installing 64bit SFML?

9
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 01:14:30 am »
Ok guys nvm I figured that part out.  My directory was wrong, and apparently SFML was expecting to be ran in x86 so I changed to that.  Now I need to copy my SFML DLL files "to the directory where your compiled executable is" -the tutorial page I originally mentioned.

Probably a dumb question but where can I find my compiled executable?
I just need to copy my DLL's there and I think everything should work.

10
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 12:47:38 am »
I tried quotes around the include at the beginning, still doesn't work.  I will tell you what I have done from the start and if you wouldn't mind trying to see if I did something wrong then that would be amazing.  First, I downloaded SFML C++ 17 32 bits.  I unzipped the folder, but left it in downloads.  I went into a blank, fresh project on Visual Studio 2022.  Btw my language is C++ 17.  I went into project properties, then into configuration properties, then into C/C++, then into general.  I made sure to set configuration to all configurations, and platform to Active(x64).  Under Additional Include Directories, I put C:\users\xxxxxx\Downloads\SFML-2.6.1-windows-vc17-32-bit\SFML-2.6.1\include\SFML.  Then I went into Linker/General, and under Additional Library Directives I put C:\users\xxxxxx\Downloads\SFML-2.6.1-windows-vc17-32-bit\SFML-2.6.1\lib.  After that I went into Linker\Input and under additional dependencies, before all the rest of the stuff, I inserted sfml-graphics.lib;sfml-window.lib;sfml-system.lib;.

Sry bout the big chunk of text but if you see anything I did wrong please tell me.

11
General / Can't get SFML on VS 2022
« on: February 07, 2024, 01:40:42 am »
So I am trying to get SFML, and I want to get into C++ coding.  I am very new to this.  I followed this tutorial: https://www.sfml-dev.org/tutorials/2.6/start-vc.php, after installing SFML C++ 17 32 bit.  I am using Visual Studio 2022 with C++ 17.  I added to my properties what the pictures in the tutorial said, but now every time I try to include the sfml library or do anything it says: Error C1083 Cannot open include file: 'SFML/Graphics.hpp': No such file or directory Project C:\Users\xxxxx\source\repos\Project\sfmlproject\Source.cpp.  I have no idea what is wrong please help me.

Pages: [1]