[QUOTE=mechanarchy;33593585]Do whatever that says, then make a new constructor in your main form with a single parameter, string userName.
You should find a constructor automatically generated, so you can just edit that one if you like.[/QUOTE]
How do I pass the variable to the constructer? When I create a new instance of the main form and add a parameter it gives me an error.
I only have the most basic understanding of how threaded programs work, but I'd like to move my pathfinding algorithm into a separate thread so that it doesn't cause my entire program to hang while individual units try to construct a path. I'm using Java and Slick2D if that matters. Am I making sense?
[editline]6th December 2011[/editline]
Uh, I think I did it.
[cpp]
nv = new NavThread(position, target);
nv.run();
if (!nv.isAlive())
path = nv.getPath();
if (path == null)
return;[/cpp]
[cpp]public class NavThread extends Thread
{
Vector2f start;
Vector2f goal;
MovePath path;
public NavThread(Vector2f startv, Vector2f goalv)
{
this.start = startv;
this.goal = goalv;
}
public void run()
{
path = NavigationManager.findPath(start, goal);
}
public MovePath getPath()
{
return path;
}
}[/cpp]
Tought It would do no harm reposting here:
I'm working on a simple engine for the Android Platform, using pure JDK (no native code).
Problem is, I can seem to figure how the hell am I supossed to push structs into the GLSL Shader, so that I can start working with Light and stuff.
Most of the code is there already, loading .obj files, basic touch events, textures, etc.
Help or Documentation would be great, code snippets could help, but I'd rather have a good doc on it.
(Please keep in mind that this is the FIRST TIME I'm using OpenGL)
[editline]6th December 2011[/editline]
[QUOTE=IAmAnooB;33595853]I am trying to code a simple game in C# (with xna) that will use a grid/squares. I can't think of a smart solution, anybody that have made something similar? Code is not that needed, what I need is the theoretical part.[/QUOTE]
Basically, my two favorite approaches are using a HUGE file with characters, but the easy implementations of such limits you to 254 entities, in case you need more, you can use a .png or .bmp file and extract the color of said point and calculate the number ID of the entity.
In case you need a 2d map editor, the image approach is easier, or I could give you my editor and you would port it to lazarus and edit it.
swebonny why in the world are you closing people's question threads??
might as well close every single thread other than this and WAYWO
Okay, I give up now and have to ask for help.
I want to figure out the deltatime, the time it takes for each of my frames to pass so I can calculate an fps. I work in c++ with opengl and don't use any external libraries.
[cpp]
double PCFreq = 0;
void WarmupCounter()
{
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
PCFreq = double( 1000.0 / li.QuadPart );
}
__int64 StartCounter()
{
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
return( __int64 ) li.QuadPart;
}
double GetCounterSinceStartMillis(__int64 sinceThisTime)
{
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
return double( ( li.QuadPart-sinceThisTime ) * PCFreq );
}
[/cpp]
I use this as my timer. To calculate dt:
[cpp]
double current = 0, last = 0,dt = 0;
WarmupCounter();
__int64 start = StartCounter();
last = current;
current = GetCounterSinceStartMillis( last );
game.update( dt );
game.render();
[/cpp]
Then to draw it inside the 'game' I use this:
[cpp]
GLvoid glPrint(const char *fmt, ...)
{
float length=0;
char text[512];
va_list ap;
if (fmt == NULL)
return;
va_start(ap, fmt);
vsprintf(text, fmt, ap);
va_end(ap);
for (unsigned int loop=0;loop<(strlen(text));loop++)
{
length+=agmf[text[loop]].gmfCellIncX;
}
glTranslatef(( -1880.f / 1920 ),( 900.f / 1080 ),0.0f);
glScaled( 0.025, 0.05, 0.025 );
//glPushAttrib(GL_LIST_BIT);
glListBase(base);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
//glPopAttrib();
}
glPrint( "FPS: %3.2f", 1 / deltatime );
[/cpp]
I end up with a dt ranging between 400 and 600. Ingame it just prints "1.#J". Does that mean I have less than 2 fps? I can't really believe that. Help is appreciated!
[QUOTE=icantread49;33599185]swebonny why in the world are you closing people's question threads??
might as well close every single thread other than this and WAYWO[/QUOTE]
What is the point of this thread then if everyone started to make a thread for every single question?
Do you want threads like these clotting up this section?
[url]http://www.facepunch.com/threads/1145602[/url]
[url]http://www.facepunch.com/threads/1145101?p=33557863&viewfull=1#post33557863[/url]
[url]http://www.facepunch.com/threads/1145642[/url]
Perhaps this could stay open, but it's still a question.
[url]http://www.facepunch.com/threads/1145770[/url]
I thought this section needed some moderation, because I tend to see complaints.
[editline]6th December 2011[/editline]
I mean do you think I do this for fun?
I'm wasting my time here trying to clean this section up and here you come complaining even though I've never seen you help anyone.
Well as you wish, I'll reopen the threads.
[QUOTE=Swebonny;33599742]What is the point of this thread then if everyone started to make a thread for every single question?
Do you want threads like these clotting up this section?
[url]http://www.facepunch.com/threads/1145602[/url]
[url]http://www.facepunch.com/threads/1145101?p=33557863&viewfull=1#post33557863[/url]
[url]http://www.facepunch.com/threads/1145642[/url]
Perhaps this could stay open, but it's still a question.
[url]http://www.facepunch.com/threads/1145770[/url]
I thought this section needed some moderation, because I tend to see complaints.
[editline]6th December 2011[/editline]
I mean do you think I do this for fun?
I'm wasting my time here trying to clean this section up and here you come complaining even though I've never seen you help anyone.
Well as you wish, I'll reopen the threads.[/QUOTE]
I though you did quite a good job, at least you're a hard working mod nevertheless.
Tho I though that I had to open a new thread due to the scope of the question I was asking.
[QUOTE=Swebonny;33599742]What is the point of this thread then if everyone started to make a thread for every single question?[/quote]
there's absolutely no justification for having this thread. mini-questions go in WAYWO anyways and bigger question get their own threads
[quote]
I'm wasting my time here trying to clean this section up and here you come complaining even though I've never seen you help anyone.[/QUOTE]
this is maybe the second time i've even opened this thread, i help around more in WAYWO and individual threads
I think I'll do this.
I'll leave the threads alone, except one liners and really awful threads. Rate accordingly so that I know if it's worth removing or not ;)
[QUOTE=Swebonny;33600228]I think I'll do this.
I'll leave the threads alone, except one liners and really awful threads. Rate accordingly so that I know if it's worth removing or not ;)[/QUOTE]
Good approach.
[editline]6th December 2011[/editline]
Also making recruitment threads without prototypes/demos/design documents should be a bannable offense.
Yeah, it's easier to follow what's going on when someone's problem-solving process isn't spread over five pages, interrupted by a million other topics.
[QUOTE=Nigey Nige;33600597]Also making recruitment threads without prototypes/demos/design documents should be a bannable offense.[/QUOTE]
If they don't provide any info because they're paranoid that someone is going to steal their idea it should.
I bet that its a easy solution to this, but I cannot find it, but well. I've almost just started with python, got a bit of programming experience from the past. Added different modules/libs to it before (wxpython, pywin32, u3d), but I cannot find a way to get pyogre to work.
I've followed the easy steps exactly(python setup.py install), tried with different versions of python (2.6 32bit, 2.6 64bit, 2.7 64bit), different versions of pyogre and even tried with linux. Clean install of both ogre and python each time. And each time I get the same error:
[code]
Linux:
>>> import ogre.renderer.OGRE
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/ogre/renderer/OGRE/__init__.py", line 10, in <module>
from _ogre_ import *
ImportError: No module named _ogre_
Win7 64bit:
>>> import ogre.renderer.OGRE
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\site-packages\ogre\renderer\OGRE\__init__.py", line 10,
in <module>
from _ogre_ import *
ImportError: DLL load failed: %1 is not a valid Win32 application.
[/code]
None of the ogre demos, or the beginner tutorial will work with this error. However, importing ogre.renderer or just ogre works just fine, no errors :/
Anyone with Source experience? How do I get the current server's name and/or IP client-side?
e: Found it. They're in two cvars, hostname and hostip (with some bit operations). I'm awful at googling Source-related stuff :downs:
Just wondering if anyone knows how to convert a position on the screen to a position in game based on size rotation and offset? I have an ingame camera with rotation offset and a screen size.
this is what i have at the moment but it doesn't work that well\
Also all the bge_Vector is is a vector with like v.X and v.Y and basic operators like v.Add(v2);
[CODE]
public BGE_Vector getMousePos()
{
try
{
BGE_Vector mouse = new BGE_Vector(Mouse.getX(),Height -Mouse.getY());
double mx = Camera.getCenter().X;
double my = Camera.getCenter().Y;
mouse.multiply(Camera.getZoom().X, Camera.getZoom().Y);
mouse.subtract(Camera.Pos.X, Camera.Pos.Y);
double x = (mouse.X - mx);
double y = (mouse.Y - my);
double angle = -Math.toRadians(Camera.Rotation);
double nX=x*Math.cos(angle)-y*Math.sin(angle);
double nY=x*Math.sin(angle)+y*Math.cos(angle);
BGE_Util.Debug(""+mouse.Y);
return new BGE_Vector(nX + mx,nY + my);
}
catch(Exception e)
{
return BGE_Vector.ZERO();
}
}[/CODE]
Are you trying to get a ray in a 3D world? If so you need to use "Unproject"ing.
[url]http://www.xbdev.net/xna/objectpicking/index.php[/url]
[QUOTE=icantread49;33600204]there's absolutely no justification for having this thread. mini-questions go in WAYWO anyways and bigger question get their own threads
this is maybe the second time i've even opened this thread, i help around more in WAYWO and individual threads[/QUOTE]
Mini questions should go here but I often do find it hard to decide where to post them. WAYWO usually gives it more views and there's a bigger chance to get someone experianced to help but the point of this thread should be to have willing members come here, look through the questions and help with what they can.
Does anyone know what could be causing this?
[img]http://i.imgur.com/dX6LO.png[/img]
Here's the code I'm using to render those, which are supposed to be cars...
[cpp]
struct Car
{
sf::Image image;
sf::Sprite sprite;
float x, y, r;
Car(std::string& color, float _x, float _y, float _r);
void Draw(sf::RenderTarget& target);
};
// ...
MainMenuBackground::Car::Car(std::string& color, float _x, float _y, float _r)
: x(_x), y(_y), r(_r)
{
std::stringstream path;
path << "assets/cars/" << color << ".png";
image.LoadFromFile(path.str());
image.SetSmooth(false);
sprite.SetImage(image);
sprite.SetCenter(32, 32);
}
void MainMenuBackground::Car::Draw(sf::RenderTarget& target)
{
sprite.SetPosition(x, y);
sprite.SetRotation(r);
target.Draw(sprite);
}
[/cpp]
[QUOTE=swift and shift;33609944]Does anyone know what could be causing this?
Here's the code I'm using to render those, which are supposed to be cars...
[/QUOTE]
The images arent being loaded correctly not sure why that could be tho
And by that I mean that the program cant find the files
[QUOTE=Richy19;33610162]The images arent being loaded correctly not sure why that could be tho
And by that I mean that the program cant find the files[/QUOTE]
[code]std::cout << image.LoadFromFile(path.str()) << std::endl;[/code]
prints '1'
Hmm, well its definitelly the same thing that happens when loading a file fails, are you loading the files before you create the window?
Because I found that on linux the images didnt show correctly unless you load them after the openGL context has been created.
Well, the sf::Image [b]is[/b] being loaded correctly, there's no doubt in that. I think that the problem is that the sf::Image is deleted before the sprite itself is drawn, causing it to have the same effect as the image not being loaded correctly.
I'm having the same problem with my game. I can fix it by just sending the sf::Image everytime I'm gonna draw an entity, but that's not too efficient so I'm open to suggestions :v:
Are you sure the constructor is being called?
Okay, I give up now and have to ask for help.
I want to figure out the deltatime, the time it takes for each of my frames to pass so I can calculate an fps. I work in c++ with opengl and don't use any external libraries.
[cpp]
double PCFreq = 0;
void WarmupCounter()
{
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
PCFreq = double( 1000.0 / li.QuadPart );
}
__int64 StartCounter()
{
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
return( __int64 ) li.QuadPart;
}
double GetCounterSinceStartMillis(__int64 sinceThisTime)
{
LARGE_INTEGER li;
QueryPerformanceCounter(&li);
return double( ( li.QuadPart-sinceThisTime ) * PCFreq );
}
[/cpp]
I use this as my timer. To calculate dt:
[cpp]
double current = 0, last = 0,dt = 0;
WarmupCounter();
__int64 start = StartCounter();
last = current;
current = GetCounterSinceStartMillis( last );
game.update( dt );
game.render();
[/cpp]
Then to draw it inside the 'game' I use this:
[cpp]
GLvoid glPrint(const char *fmt, ...)
{
float length=0;
char text[512];
va_list ap;
if (fmt == NULL)
return;
va_start(ap, fmt);
vsprintf(text, fmt, ap);
va_end(ap);
for (unsigned int loop=0;loop<(strlen(text));loop++)
{
length+=agmf[text[loop]].gmfCellIncX;
}
glTranslatef(( -1880.f / 1920 ),( 900.f / 1080 ),0.0f);
glScaled( 0.025, 0.05, 0.025 );
//glPushAttrib(GL_LIST_BIT);
glListBase(base);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
//glPopAttrib();
}
glPrint( "FPS: %3.2f", 1 / deltatime );
[/cpp]
I end up with a dt ranging between 400 and 600. Ingame it just prints "1.#J". Does that mean I have less than 2 fps? I can't really believe that. Help is appreciated!
[QUOTE=swift and shift;33609944]Here's the code I'm using to render those, which are supposed to be cars...
[cpp]
struct Car
{
sf::Image image;
sf::Sprite sprite;
//et al
};
MainMenuBackground::Car::Car //etc
{
image.LoadFromFile(path.str());
sprite.SetImage(image);
}
[/cpp][/QUOTE]
I assume this is purely for testing, but you're supposed to create sf::Images once and then refer to them multiple times in sf::Sprites. If you keep re-creating your Image you'll keep reloading the file and bloat out your memory usage.
[QUOTE=swift and shift;33609944]Does anyone know what could be causing this?
[img]http://i.imgur.com/dX6LO.png[/img]
Here's the code I'm using to render those, which are supposed to be cars...
[cpp]
struct Car
{
sf::Image image;
sf::Sprite sprite;
float x, y, r;
Car(std::string& color, float _x, float _y, float _r);
void Draw(sf::RenderTarget& target);
};
// ...
MainMenuBackground::Car::Car(std::string& color, float _x, float _y, float _r)
: x(_x), y(_y), r(_r)
{
std::stringstream path;
path << "assets/cars/" << color << ".png";
image.LoadFromFile(path.str());
image.SetSmooth(false);
sprite.SetImage(image);
sprite.SetCenter(32, 32);
}
void MainMenuBackground::Car::Draw(sf::RenderTarget& target)
{
sprite.SetPosition(x, y);
sprite.SetRotation(r);
target.Draw(sprite);
}
[/cpp][/QUOTE]
How are you storing your Car instances?
[QUOTE=icantread49;33600204]there's absolutely no justification for having this thread. mini-questions go in WAYWO anyways and bigger question get their own threads
this is maybe the second time i've even opened this thread, i help around more in WAYWO and individual threads[/QUOTE]
You can only blame yourself, you started the V1 :v:
Can anyone help me learn to package and export my Slick2D games without just giving people my entire project folder?
If you're not familiar with it, it's a 2D game library based on LWJGL (lightweight Java game library).
Hey, need a hand with java. I have a program for inputting and outputting a number of stored records (a simple learning exercise in classes), and I want the outputs to have the same amount of spaces so they stay in columns. So right now I have
[code] Number | Name | Result
--------------------------------
0001 | Joe | 45
0002 | Jack | 52
[/code]
Where I want it all lined up, like this
[code]
Number | Name | Result
-----------------------
0001 | Joe | 45
0002 | Jack | 52
[/code]
Is there a method or something for this I can't find? Or some other simple-ish way? (My actual code has a lot more information to display but that's essentially what it needs to do
[QUOTE=fylth;33614634]Hey, need a hand with java. I have a program for inputting and outputting a number of stored records (a simple learning exercise in classes), and I want the outputs to have the same amount of spaces so they stay in columns. So right now I have
[code] Number | Name | Result
--------------------------------
0001 | Joe | 45
0002 | Jack | 52
[/code]
Where I want it all lined up, like this
[code]
Number | Name | Result
-----------------------
0001 | Joe | 45
0002 | Jack | 52
[/code]
Is there a method or something for this I can't find? Or some other simple-ish way? (My actual code has a lot more information to display but that's essentially what it needs to do[/QUOTE]
You want:
[cpp]
number + "\t" + "|" + name + "\t" + "|" + result;
[/cpp]
Sorry, you need to Log In to post a reply to this thread.