OK, thanks.
[editline]03:37PM[/editline]
Great, another problem. It probably has a very simple solution. How do I keep the variables from printing? I might do
var example = document.write("example") and it outputs example without me telling it to. And a side note, I can't put it in the <head> section, otherwise the code will fail completely.
Is there a way to get Mouse [B]Click[/B] coordinates in SFML?
Because App.GetInput().GetMouseX/Y is coordinates in general, not click coordinates.
[QUOTE=NotMeh;23700211]Is there a way to get Mouse [B]Click[/B] coordinates in SFML?
Because App.GetInput().GetMouseX/Y is coordinates in general, not click coordinates.[/QUOTE]
Use the MouseButtonPressed event - it contains coordinates.
when I try to pass Event.MouseButtonEvent.X into a function it just gives me a "invalid use of struct" error
:eng99:
Ok guys, not a programming question, but more of a game design question.
I'm trying to make a 2D multiplayer speluking (cave exploring/mining game) game where players can modify the terrain.
Now, if I have only one "layer" within the game, that would be pretty easy. I could just have all of the terrain be 'tiles' that players can mine away leading to basically very linear areas (which is boring).
However, that is not what I want to do -- I want the players to be able to mine or add terrain tiles such that they can modify the foreground or the background terrain to create different terraces on which they can walk.
The problem I have with this is programmatically figuring out where the terrain collisions will be.
It's probably easier to show a picture...
[IMG]http://i.imgur.com/y8J1q.png[/IMG]
Let's say that you start with the flat terrain on the bottom. Eventually you want to come along and build a small hill and then I dunno.. put a windmill on top. You place four rows of dirt tiles to create a second level that you can stand on while still being able to walk along the bottom level.
On the left side where I have steps, I want there to be collisions such that the player can't be standing on the step and then walk right and fall off the step -- instead he runs into the dirt wall and has to either jump up and to the right, or move left and down. On the other hand, on the far right side, I want the player to be able to walk through without colliding.
Basically, I'm just having a hard time even imagining an algorithm or game mechanic that would allow players to do that without allowing them to create stupid terrain traps that are impossible to get around or lead to other players getting stuck. I'll try to explain better in the future :)
[QUOTE=NotMeh;23700535]when I try to pass Event.MouseButtonEvent.X into a function it just gives me a "invalid use of struct" error
:eng99:[/QUOTE]
nevermind, figured this one out :buddy:
Fuuuck, I really hate naming shit.
[cpp]public int CantThinkOfName(double d)
{
if (d < .5)
return -1;
else if (d > .5)
return 1;
return 0;
}[/cpp]
[QUOTE=high;23702751]Fuuuck, I really hate naming shit.
[cpp]public int CantThinkOfName(double d)
{
if (d < .5)
return -1;
else if (d > .5)
return 1;
return 0;
}[/cpp][/QUOTE]
[cpp]public int CantThinkOfName(double d)
{
return ( d < .5 ) ? ( -1 ) : ( d > .5 ) ? ( 1 ) : 0;
}
[/cpp]
n__n
[QUOTE=Shammah;23703359]That's disgusting.[/QUOTE]
But it's short and uh... I dunno?
[QUOTE=esalaka;23703487]But it's short and uh... I dunno?[/QUOTE]
It's short and way less readable.
Normally I'm an advocate of using shortcuts in code, but in this case, the code with the series of if's was so much more readable than yours
[editline]08:18PM[/editline]
[QUOTE=Spartan One;23692638]var example = document.[b]write[/b]("example") and it outputs example [b]without me telling it to[/b].[/QUOTE]
Are you kidding me?
[QUOTE=esalaka;23703259][cpp]public int CantThinkOfName(double d)
{
return ( d < .5 ) ? ( -1 ) : ( d > .5 ) ? ( 1 ) : 0;
}
[/cpp]
n__n[/QUOTE]
Typical example of "asshole" code as described in the article mentioned elsewhere in the programming forum
[QUOTE=Chris220;23703967]Typical example of "asshole" code as described in the article mentioned elsewhere in the programming forum[/QUOTE]
But I am an asshole, am I not?
Not really, you just hate everything :v:
[QUOTE=Chris220;23704367]Not really, you just hate everything :v:[/QUOTE]
I don't hate efex.
UNLIKE ALL OF YOU!
As stated by my first (and last so far) assembly program, I find efeX to be a delightful gentleman
[QUOTE=Inside;23702575]Ok guys, not a programming question, but more of a game design question.
I'm trying to make a 2D multiplayer speluking (cave exploring/mining game) game where players can modify the terrain.
Now, if I have only one "layer" within the game, that would be pretty easy. I could just have all of the terrain be 'tiles' that players can mine away leading to basically very linear areas (which is boring).
However, that is not what I want to do -- I want the players to be able to mine or add terrain tiles such that they can modify the foreground or the background terrain to create different terraces on which they can walk.
The problem I have with this is programmatically figuring out where the terrain collisions will be.
It's probably easier to show a picture...
[url]http://i.imgur.com/y8J1q.png[/url]
Let's say that you start with the flat terrain on the bottom. Eventually you want to come along and build a small hill and then I dunno.. put a windmill on top. You place four rows of dirt tiles to create a second level that you can stand on while still being able to walk along the bottom level.
On the left side where I have steps, I want there to be collisions such that the player can't be standing on the step and then walk right and fall off the step -- instead he runs into the dirt wall and has to either jump up and to the right, or move left and down. On the other hand, on the far right side, I want the player to be able to walk through without colliding.
Basically, I'm just having a hard time even imagining an algorithm or game mechanic that would allow players to do that without allowing them to create stupid terrain traps that are impossible to get around or lead to other players getting stuck. I'll try to explain better in the future :)[/QUOTE]
This is an interesting question, here's how I'd do it:
Have a number of layers like you currently do, where the ground floor is layer0 and those blocks above are layer1 or whatever. Then you can keep a track of the layer the player is currently on.
Now, vertical collisions: they should happen regardless of what layer the guy is on, but the guy should only collide if he lands on top but not if he is travelling upwards. Once the guy lands on a horizontal ground, his current layer switches to the layer of this floor.
Horizontal collisions: they should only happen if he is on the respective layer.
So in your diagram, the bottom guy is on layer0 so he can walk left and right as much as he wants, but he can also jump up through the step, land on the step, and now he is on layer1.
Once on this layer, he can't move right but he can move left and drop down onto layer0 and then move right.
How can I use static sf::image? I always get "error LNK2001: unresolved external symbol "public: static class sf::Image tile::tileimg" (?tileimg@tile@@2VImage@sf@@A)"
You have to define tile::tileimg somewhere in a code file. e.g.
[cpp]sf::Image tile::tileimg;[/cpp]
This is going to sound stupid but im just starting out in c# and im trying to show a form something which in VB was easy with Form.Show
but all though in msdn it says you can do the same if i put that in it comes up with this error
An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Control.Show()'
You need to call that method on an instance of the Form class.
You probably have Form form1 = new Form (); or something like that in the code. Then you do form1.Show();
Don't tell me the code doesn't work because it's not supposed to in this state.
i cant find the new form thing
FYI im using Visual C# 2k8 and i just clicked add about form in the solution explorer
Thanks overv, but do you know how static image could have possibly broken my collision?
Click around the files in the solution explorer.
I've recently been learning C++ and right now I'm toying around with some file I/O. While doing this I decided to try making a little program that would make a bitmap file. While I eventually got it working I noticed that for some reason when writing a number of type "short" as part of a structure to a file, it would be written as four bytes even though I've read that it is only supposed to be two. Here is an example of what I mean
[cpp]#include <iostream>
#include <fstream>
int main(int argc, char* argv[])
{
struct test
{
short t1;
int t2;
short t3;
int t4;
};
test test1;
test1.t1 = 1;
test1.t2 = 2;
test1.t3 =3;
test1.t4 = 4;
std::ofstream file("meh", std::ios::binary);
file.write(reinterpret_cast<char*>(&test1), 12);
std::cin.get();
}[/cpp]
This will only write the first three numbers to the file because the two "short" variables are being written as four bytes. Does anyone know why this does that?
[QUOTE=cyber_5;23709107]I've recently been learning C++ and right now I'm toying around with some file I/O. While doing this I decided to try making a little program that would make a bitmap file. While I eventually got it working I noticed that for some reason when writing a number of type "short" as part of a structure to a file, it would be written as four bytes even though I've read that it is only supposed to be two. Here is an example of what I mean
[cpp]#include <iostream>
#include <fstream>
int main(int argc, char* argv[])
{
struct test
{
short t1;
int t2;
short t3;
int t4;
};
test test1;
test1.t1 = 1;
test1.t2 = 2;
test1.t3 =3;
test1.t4 = 4;
std::ofstream file("meh", std::ios::binary);
file.write(reinterpret_cast<char*>(&test1), 12);
std::cin.get();
}[/cpp]
This will only write the first three numbers to the file because the two "short" variables are being written as four bytes. Does anyone know why this does that?[/QUOTE]
It has to do with alignment of a structure.
Click [url=http://stackoverflow.com/questions/833526/why-short-is-stored-as-4-bytes-in-a-struct-in-c]here[/url] for further reading.
[editline]19:25[/editline]
You may try and optimize the structure of the struct (:v:), but instead of telling the program to read in 12 bytes as hardcoded, you're better of passing it the parameter sizeof(test1)
[QUOTE=Shammah;23709376]It has to do with alignment of a structure.
Click [url=http://stackoverflow.com/questions/833526/why-short-is-stored-as-4-bytes-in-a-struct-in-c]here[/url] for further reading.[/QUOTE]
That explains a lot. I'll have to take that into consideration in the future. Thank you.
[QUOTE=cyber_5;23709442]That explains a lot. I'll have to take that into consideration in the future. Thank you.[/QUOTE]
slightly off-topic, I thought I was special with 60 posts since 2007, but you crossed the line even further :v:
So after using lua for awhile I thought I'd try C#, and it's similar enough that I'm comfortable with it's structure. I want to try making a simple game, so XNA seemed like a logical choice.
However I wanted to download a 2d physics engine for XNA, and it seems that any I find do not work with XNAGS4 and/or VS2010.
Anyone have a suggestion for something other than XNA, or a compatible set of physics?
I think people said that Box2D is good, not sure.
Off-topic, are you still regular on the FSG forums or did you stop posting there?
Sorry, you need to Log In to post a reply to this thread.