[QUOTE=ZenX2;26574962]Yes. I found it extremely helpful, both for programming and as a flat surface for my mouse pad.[/QUOTE]
Huh? You need to use a book to make a flat surface? What kind of desk do you have? :v:
Unless you have a laptop or something.
OK, then it is settled. I shall buy the book at a quarter past dawn. I think that is 6:15am....
why that exact time?
Ebay?
[QUOTE=Richy19;26575512]why that exact time?
Ebay?[/QUOTE]
I think he means "tommorow morning" but wanted to make his post more exciting. :v:
Yeah. And no, amazon.
Ok, I got gravity working properly, but now the particles keep flinging themselves in a direction.
[editline]8th December 2010[/editline]
Oh wait. I know why. The particles are close on their individual plane. Fucking vectors, how do they work?
How do I change the back ground color of the JOptionPane? Here is code if it helps:
[code]import javax.swing.JOptionPane;
import java.awt.Color;
import java.lang.String;
import java.util.prefs.Preferences;
public class EightBall
{
public static void main ( String args[] )
{
JOptionPane panel = new JOptionPane();
WishGenerator responseGenerator = new WishGenerator();
String compliant = panel.showInputDialog( "Make a wish..." );
panel.showMessageDialog(null, responseGenerator.generateRandomSentence(), "Response",
panel.PLAIN_MESSAGE);
}
} [/code]
[code]
import java.util.Random;
public class WishGenerator
{
private String[] sentenceArray = {"As I see it, yes.", "It is certain.", "It is decidedly so.", "Most likely.", "Outlook: good.", "Signs point to yes.",
"Without a doubt.", "Yes.", "You may rely on it.", "Reply hazy, try again.", "Ask again later.", "Concentrate and ask again.", "Better not tell you now...", "Don't count on it.",
"My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful."};
private Random randGen = new Random();
public String generateRandomSentence()
{
String sentence =
sentenceArray[randGen.nextInt(sentenceArray.length)] + " ";
return sentence;
}
public static void main(String[] args)
{
WishGenerator wishGen = new WishGenerator();
for(int i = 0; i < 1; i++)
{
}
}
}
[/code]
[QUOTE=bootv2;26588128]tried png, completely white again, while the original file is red. I'm sure it's drawed because of the green background. and it does have the correct dimensions.[/QUOTE]
I white sprite means the original image object has been lost or destroyed.
[QUOTE=bootv2;26588179]how comes? I can use the file in every other app and I'm sure it's being opened becuase of the [cpp]if (!Image.LoadFromFile("testsprite.png"))
{
return EXIT_FAILURE;// Error...
}[/cpp]code.
I've checked that no other apps are using the file at runtime.[/QUOTE]
Can you post the whole code? It sounds like the Image object is lost somewhere, probably by going out of scope.
[code]sf::Image Image;
if (!Image.LoadFromFile("testsprite.png"))
{
return EXIT_FAILURE;
}
[/code]
that should be outside the while (App.IsOpened())
At the moment your creating a new sf::Image on each loop, have you not noticed your computer slowing down or anything? that looks like a pretty big memory hog there
BTW same goes for [code]// Display window contents on screen
sf::Sprite Sprite;
//setting sprite position
Sprite.SetPosition(200.5f, 100.5f);
//setting sprite image
Sprite.SetImage(Image);[/code]
this should work for you[code]
#include "SFML/graphics.hpp"
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(680, 420, 64), "SFML Graphics");
sf::Image Image;
if (!Image.LoadFromFile("testsprite.png"))
{
return EXIT_FAILURE;
}
// Display window contents on screen
sf::Sprite Sprite;
//setting sprite position
Sprite.SetPosition(200.5f, 100.5f);
//setting sprite image
Sprite.SetImage(Image);
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
// Clear the screen (fill it with black color)
App.Clear(sf::Color(97, 201, 53));
//drawing sprite on display and displaying the drawed display
App.Draw(Sprite);
App.Display();
}
return EXIT_SUCCESS;
}[/code]
[code]import javax.swing.JOptionPane;
import java.lang.String;
import java.util.Scanner;
public class EightBall
{
public static void main ( String args[] )
{
int test;
Scanner scan = new Scanner (System.in);
JOptionPane panel = new JOptionPane();
WishGenerator responseGenerator = new WishGenerator();
String blarg = panel.showInputDialog("Do you want to make a wish?" );
test = scan.nextInt();
if(blarg.equals("yes") || blarg.equals("Yes"))
{
test = 1;
}
if(blarg.equals("no") || blarg.equals("No"))
{
test = 2;
}
if( test == 1)
{
String name = panel.showInputDialog("What is your name?");
String compliant = panel.showInputDialog("Make a wish " + name);
panel.showMessageDialog(null, responseGenerator.generateRandomSentence(), "Response",
panel.PLAIN_MESSAGE);
}
if(test == 2)
{
String lol = panel.showInputDialog("Fine!");
}
}
}
[/code]
The problem is that it will show up in the pane with "Do you want to make a wish?" and if you type yes || no it freaks out and pritns an empty imput box into the console. If you type in it,... Well... java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at EightBallTEST.main(EightBallTEST.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:271)
I think we may have a problem.
[url=http://download.oracle.com/javase/6/docs/api/java/util/InputMismatchException.html]java.util.InputMismatchException[/url]
[code]at java.util.Scanner.nextInt(Unknown Source)[/code]
You probably don't even need that Scanner anyways.
[QUOTE=ZeekyHBomb;26589919][url=http://download.oracle.com/javase/6/docs/api/java/util/InputMismatchException.html]java.util.InputMismatchException[/url]
[code]at java.util.Scanner.nextInt(Unknown Source)[/code]
You probably don't even need that Scanner anyways.[/QUOTE]
So, what are you saying exactly needs to be done?
If I am correct and you don't need it, remove all code related to the Scanner.
If I am not, input an integer or catch that exception and yell at the user for not inputting an int.
I'm trying to get openGL to take a picture of each step of the simulation so I can merge them all into a video. The output was odd and I'm not sure how to fix this.
[img]http://img64.imageshack.us/img64/6855/simy.png[/img]
I think it needs a bitwise shift, but I'm not sure how to go about doing that.
Any Idea how i can iterate every file in a directory? They are *.ini files, i need to change some values. Im using C++ under Windows. Thanks
[QUOTE=ncls_hv;26594512]Any Idea how i can iterate every file in a directory? They are *.ini files, i need to change some values. Im using C++ under Windows. Thanks[/QUOTE]
If you don't mind binding yourself to Windows there are lots of examples using the Windows API, just google. Otherwise you could use Boost.
[QUOTE=Niteshifter;26592960]I'm trying to get openGL to take a picture of each step of the simulation so I can merge them all into a video. The output was odd and I'm not sure how to fix this.
[img_thumb]http://img64.imageshack.us/img64/6855/simy.png[/img_thumb]
I think it needs a bitwise shift, but I'm not sure how to go about doing that.[/QUOTE]
Can you post how you're taking the picture, as well as your file writing function? Also, tga is the easiest format to use if you're going to write your own function.
Has anyone here gotten doxygen to work with external documentation files? That is, if I have a file containing a class, I can give doxygen a different file to produce the documentation from? I find having them placed the way it is normally done to be a bit distracting, and would like the option to throw everything into a separate folder.
[QUOTE=Metroid48;26596834]Can you post how you're taking the picture, as well as your file writing function? Also, tga is the easiest format to use if you're going to write your own function.[/QUOTE]
I'm using TGA. I found this off a site and modified it a bit.
[code]
void scrn(int nShot)
{
char cFileName[64];
FILE *fScreenshot;
int nSize = 250*250*3;
GLubyte *pixels = new GLubyte [nSize];
if (pixels == NULL)
{
printf("pixels == null\n");
return;
}
sprintf(cFileName, "sim_%d.tga", nShot);
fScreenshot = fopen(cFileName, "wb");
if(fScreenshot == NULL)
{
printf("fScreenshot == null\n");
return;
}
glReadPixels(0, 0, 250, 250, GL_RGB, GL_UNSIGNED_BYTE, pixels);
unsigned char TGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0};
unsigned char header[6] = {250%256,250/256,250%256,250/256,24,0};
fwrite(TGAheader, sizeof(unsigned char), 12, fScreenshot);
fwrite(header, sizeof(unsigned char), 6, fScreenshot);
fwrite(pixels, sizeof(GLubyte), nSize, fScreenshot);
fclose(fScreenshot);
delete [] pixels;
return;
}
[/code]
I also have it so the points are rendering in one channel: glColor3f(0.0,1.0,0.0);
[QUOTE=Metroid48;26596834]Can you post how you're taking the picture, as well as your file writing function? Also, tga is the easiest format to use if you're going to write your own function.[/QUOTE]
Isn't bmp the easiest format?
[QUOTE=bootv2;26603055]I'm using sfml 2.0 but I'm learning form the 1,6 tutorial. I've tried searching inside the documentation without success for the equalivent of: sf::String Text;
Text.SetText("Hello");
Text.SetFont(GameFont);
Text.SetSize(30); which tells me settext setfont and setsize are not a member of sf::string[/QUOTE]
sf::String is [url=http://sfml-dev.org/documentation/2.0/classsf_1_1Text.htm]sf::Text[/url] in 2.0
[QUOTE=Niteshifter;26598908]I'm using TGA. I found this off a site and modified it a bit.
[code]
void scrn(int nShot)
{
char cFileName[64];
FILE *fScreenshot;
int nSize = 250*250*3;
GLubyte *pixels = new GLubyte [nSize];
if (pixels == NULL)
{
printf("pixels == null\n");
return;
}
sprintf(cFileName, "sim_%d.tga", nShot);
fScreenshot = fopen(cFileName, "wb");
if(fScreenshot == NULL)
{
printf("fScreenshot == null\n");
return;
}
glReadPixels(0, 0, 250, 250, GL_RGB, GL_UNSIGNED_BYTE, pixels);
unsigned char TGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0};
unsigned char header[6] = {250%256,250/256,250%256,250/256,24,0};
fwrite(TGAheader, sizeof(unsigned char), 12, fScreenshot);
fwrite(header, sizeof(unsigned char), 6, fScreenshot);
fwrite(pixels, sizeof(GLubyte), nSize, fScreenshot);
fclose(fScreenshot);
delete [] pixels;
return;
}
[/code]
I also have it so the points are rendering in one channel: glColor3f(0.0,1.0,0.0);[/QUOTE]
First, TGAheader looks like it's missing the colour depth. Try {0,0,2,0,0,0,0,32,0,0,0,0}
But I doubt that's causing the issue, so it's something to do with OpenGL. Use glGetError to check if there are any issues immediately after [url=http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml]glReadPixels[/url].
[editline]10th December 2010[/editline]
[QUOTE=Overv;26601430]Isn't bmp the easiest format?[/QUOTE]
If bmp's easiest then tga is tied with it! I've never used bmp but with tga you just write a simple header and then the raw data.
So, I'm working on a platformer at the moment.
I update my object's X and Y coordinates by (vx * deltaT) and (vy * deltaT) each frame, which is fine.
I then need to apply gravity and friction to these vx and vy values. Gravity is fine, but I'm a bit stuck on applying friction, taking into account deltaT.
Here's my code so far:
[cpp]x += vx * DeltaT;
y += vy * DeltaT;
vx /= Friction; // Here is where I need my DeltaT to be taken into account...
vy += Gravity * DeltaT;[/cpp]
[cpp]vx /= pow(Friction, DeltaT);[/cpp]
[QUOTE=MakeR;26605955][cpp]vx /= pow(Friction, DeltaT);[/cpp][/QUOTE]
That's brilliant, thank you!
How did you come up with that? I probably would have never thought of doing it like that :P
[QUOTE=Chris220;26606294]That's brilliant, thank you!
How did you come up with that? I probably would have never thought of doing it like that :P[/QUOTE]
Someone posted it on Facepunch a while ago, I can't remember who though.
Is there anyway to do this when NOT using a windows form project?
[url]http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx[/url]
Sorry, you need to Log In to post a reply to this thread.