If anyone is familiar with XNA (derp, I would hope so), and preferably the samples framework for Farseer, then could you possibly tell me how to have multiple renderable 'overlays'? As in, first you have the main game screen, then you would have the hud, and then maybe some noise overlay? So far, it seems like there is just GameScreen which is basically a state, and as far as I can tell you can't layer GameScreens such that they can talk to eachother...
-snip-
Anyone know a good way of finding out when a new application launches in Windows without endlessly polling?
Is it possible to reverse engineer a Firefox or Chrome add-on?
Possible and not even really reverse engineering. Download the addon and look inside the jar
[editline]15th June 2011[/editline]
I mean xpi but I think it's a jar anyway which is just a modified zip IIRC
I'm trying to make an app in java that lets you post images to your Tumblr blog. I'm using the default java.net library, and I can't figure out how to send an image in a HTTP POST request. Sending text works fine, though. Should I be using a different library?
Here's my ImagePost class as is:
[code]import java.io.*;
import java.net.*;
public class ImagePost {
String data = null;
String enc = "UTF-8";
String type;
File img;
public ImagePost(String imgPath, String caption, String tags) throws IOException {
//Construct data
type = "photo";
img = new File(imgPath);
data = URLEncoder.encode("email", enc) + "=" + URLEncoder.encode(Main.getEmail(), enc);
data += "&" + URLEncoder.encode("password", enc) + "=" + URLEncoder.encode(Main.getPassword(), enc);
data += "&" + URLEncoder.encode("type", enc) + "=" + URLEncoder.encode(type, enc);
data += "&" + URLEncoder.encode("data", enc) + "=" + img; // LOL DON'T KNOW
data += "&" + URLEncoder.encode("caption", enc) + "=" + URLEncoder.encode(caption, enc);
data += "&" + URLEncoder.encode("generator", "UTF-8") + "=" + URLEncoder.encode(Main.getVersion(), "UTF-8");
data += "&" + URLEncoder.encode("tags", "UTF-8") + "=" + URLEncoder.encode(tags, "UTF-8");
}
public void send() throws IOException {
// Set up connection
URL tumblrWrite = new URL("http://www.tumblr.com/api/write");
HttpURLConnection http = (HttpURLConnection) tumblrWrite.openConnection();
http.setDoOutput(true);
http.setRequestMethod("POST");
http.setRequestProperty("Content-Type", "image/png");
DataOutputStream dout = new DataOutputStream(http.getOutputStream());
//OutputStreamWriter out = new OutputStreamWriter(http.getOutputStream());
// Send data
http.connect();
dout.writeBytes(data);
//out.write(data);
dout.flush();
System.out.println(http.getResponseCode());
System.out.println(http.getResponseMessage());
dout.close();
}
}
[/code]
Here's my working TextPost class, if it helps:
[code]import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class TextPost {
String data = null;
String enc = "UTF-8";
public TextPost(String title, String body, String tags) throws UnsupportedEncodingException {
//Construct data
String type = "regular";
data = URLEncoder.encode("email", enc) + "=" + URLEncoder.encode(Main.getEmail(), enc);
data += "&" + URLEncoder.encode("password", enc) + "=" + URLEncoder.encode(Main.getPassword(), enc);
data += "&" + URLEncoder.encode("type", enc) + "=" + URLEncoder.encode(type, enc);
data += "&" + URLEncoder.encode("title", enc) + "=" + URLEncoder.encode(title, enc);
data += "&" + URLEncoder.encode("body", enc) + "=" + URLEncoder.encode(body, enc);
data += "&" + URLEncoder.encode("generator", "UTF-8") + "=" + URLEncoder.encode(Main.getVersion(), "UTF-8");
data += "&" + URLEncoder.encode("tags", "UTF-8") + "=" + URLEncoder.encode(tags, "UTF-8");
}
public void send() throws IOException {
// Set up connection
URL tumblrWrite = new URL("http://www.tumblr.com/api/write");
HttpURLConnection http = (HttpURLConnection) tumblrWrite.openConnection();
http.setDoOutput(true);
http.setRequestMethod("POST");
OutputStreamWriter out = new OutputStreamWriter(http.getOutputStream());
// Send data
http.connect();
out.write(data);
out.flush();
System.out.println(http.getResponseCode());
System.out.println(http.getResponseMessage());
out.close();
}
}
[/code]
[QUOTE=Nigey Nige;30471095]I'm trying to make an app in java that lets you post images to your Tumblr blog. I'm using the default java.net library, and I can't figure out how to send an image in a HTTP POST request. Sending text works fine, though. Should I be using a different library?
Here's my ImagePost class as is:
[/QUOTE]
I'm not really familiar with that specific library, but what you need to do is on the line with the comment //LOL DONT KNOW instead of putting enc there, get the image file and put a byte[] array there instead, or something like it. You need a FileReader or something like that. Maybe this will help you.
[url]http://download.oracle.com/javase/1.4.2/docs/api/java/awt/image/BufferedImage.html[/url]
I want to create a 10x10cm square, with 1cm blocks, now, I want to do this with 1-for loop. But, how would I do this with just 1 for loop? I know how to do it with 10, but, I want to learn it the fast way.
[QUOTE=bobthe2lol;30473159]I'm not really familiar with that specific library, but what you need to do is on the line with the comment //LOL DONT KNOW instead of putting enc there, get the image file and put a byte[] array there instead, or something like it. You need a FileReader or something like that. Maybe this will help you.
[url]http://download.oracle.com/javase/1.4.2/docs/api/java/awt/image/BufferedImage.html[/url][/QUOTE]
Okay, so I managed to convert the file into a byte[] array, but now I'm stuck on how to fit it in with the rest of my data in the POST request. Here's my new ImagePost class:
[code]import java.io.*;
import java.net.*;
public class ImagePost {
String data = null;
String enc = "UTF-8";
String type;
File img;
byte[] bytes;
FileReader reader;
ByteArrayOutputStream bytesOut;
public ImagePost(String imgPath, String caption, String tags) throws IOException {
//Construct data
type = "photo";
img = new File(imgPath);
bytes = fileToByteArray(img);
bytesOut = new ByteArrayOutputStream();
bytesOut.write(bytes);
data = URLEncoder.encode("email", enc) + "=" + URLEncoder.encode(Main.getEmail(), enc);
data += "&" + URLEncoder.encode("password", enc) + "=" + URLEncoder.encode(Main.getPassword(), enc);
data += "&" + URLEncoder.encode("type", enc) + "=" + URLEncoder.encode(type, enc);
data += "&" + URLEncoder.encode("data", enc) + "=" + bytes;
data += "&" + URLEncoder.encode("caption", enc) + "=" + URLEncoder.encode(caption, enc);
data += "&" + URLEncoder.encode("generator", "UTF-8") + "=" + URLEncoder.encode(Main.getVersion(), "UTF-8");
data += "&" + URLEncoder.encode("tags", "UTF-8") + "=" + URLEncoder.encode(tags, "UTF-8");
}
public byte[] fileToByteArray(File img) throws IOException {
long length = img.length();
InputStream in = new FileInputStream(img);
byte[] byteArray;
if (length > Integer.MAX_VALUE) {
System.out.println("File too large!");
return null;
}
byteArray = new byte[(int) length];
int offset = 0;
int numRead = 0;
while (offset < byteArray.length && (numRead = in.read(byteArray, offset, byteArray.length - offset)) >= 0) {
offset += numRead;
}
in.close();
return byteArray;
}
public void send() throws IOException {
// Set up connection
URL tumblrWrite = new URL("http://www.tumblr.com/api/write");
HttpURLConnection http = (HttpURLConnection) tumblrWrite.openConnection();
http.setDoOutput(true);
http.setRequestMethod("POST");
OutputStreamWriter out = new OutputStreamWriter(http.getOutputStream());
// Send data
http.connect();
out.write(data);
out.flush();
System.out.println(http.getResponseCode());
System.out.println(http.getResponseMessage());
out.close();
}
}
[/code]
But that gives me a 400 bad request error.
[QUOTE=Nigey Nige;30476077]Okay, so I managed to convert the file into a byte[] array, but now I'm stuck on how to fit it in with the rest of my data in the POST request. Here's my new ImagePost class:
But that gives me a 400 bad request error.[/QUOTE]
You seem to be URLEncoding everything else, try URLEncoding bytes too. You might need to set the MIME type or something like that... Nope, if URLEncoder doesn't do it for you, then you'll need to set the content type to image/jpeg or image/png or bmp or what ever type it is.
I need help getting the C# libraries for SFML 2.0. I followed the tutorial but when I added the DLLs to VC# it said they weren't valid libraries. Does anyone have the most recent libraries?
[QUOTE=bobthe2lol;30476591]You seem to be URLEncoding everything else, try URLEncoding bytes too. You might need to set the MIME type or something like that... Nope, if URLEncoder doesn't do it for you, then you'll need to set the content type to image/jpeg or image/png or bmp or what ever type it is.[/QUOTE]
Well, I tried setting the content type and it changed from 400 bad request to 403 forbidden. Step in the right direction, I guess? Then I tried being all like encode(bytes.toString(), enc) and still 403. It's weird, I would've thought there'd be a straightforward guide to this - which makes me think I'm going about it completely wrong. Ideas?
[QUOTE=foszor;30478690]I need help getting the C# libraries for SFML 2.0. I followed the tutorial but when I added the DLLs to VC# it said they weren't valid libraries. Does anyone have the most recent libraries?[/QUOTE]
Which DLLs did you reference? There are ones starting with csfml- which you shouldn't reference but they need to be in the same directory as your compiled .exe, and there are ones starting with sfmlnet- which you do reference.
[QUOTE=Robert64;30480458]Which DLLs did you reference? There are ones starting with csfml- which you shouldn't reference but they need to be in the same directory as your compiled .exe, and there are ones starting with sfmlnet- which you do reference.[/QUOTE]
I can't figure out how to build the sfmlnet- ones
[editline]15th June 2011[/editline]
Well wait, I was able to build sfml- dll's and then figured out how to build sfmlnet- dll's... but now its erroring asking for csfml- dlls?
Har har har, android is amazing
But, on a relevant note, does anyone know if there is a free c/c++ compiler that runs on the actual android?
[QUOTE=Kondor58;30244649][url=http://www.textbookw.com/search.asp?p=&filteryr=&genre=&alpha=&page=&source=search&searchstr=Deitel&pid=2871&pauth=Paul+J%2E+Deitel%2C+Harvey+M%2E+Deitel&pname=C%2B%2B+How+to+Program]C++ How to Program 7th Edition by Deitel[/url]: It's a great book, every chapter is a new program where the author includes plenty of code to show you how it's implemented. Also, it's huge, I'm using it for learning and as a reference book. This is the book I bought when I first started C++ and found not problems getting into it, each chapter has LOADS of practice questions and programs that you can try out to become accustomed to the techniques in each chapter. It also comes with a CD that includes basically another book's worth of optional PDF chapters including programming a 3D graphical game of Pong in OGRE.[/QUOTE]
I know that it has been quite some time since we talked, but may I ask at which pace you moved through the book on average? For the most part the document is very detailed and extensive.
[QUOTE=Icedshot;30483846]Har har har, android is amazing
But, on a relevant note, does anyone know if there is a free c/c++ compiler that runs on the actual android?[/QUOTE]
Are you talking about something to compile for the NDK?
[QUOTE=foszor;30483913]Are you talking about something to compile for the NDK?[/QUOTE]
At this point, I havent yet had a good look at how native applications really work on droid, but probably :v:
[QUOTE=Icedshot;30484053]At this point, I havent yet had a good look at how native applications really work on droid, but probably :v:[/QUOTE]
You can just use the compiler that comes with the Android NDK. [url=http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/]Here[/url] is a good guide.
[QUOTE=Overv;30484518]You can just use the compiler that comes with the Android NDK. [url=http://mobile.tutsplus.com/tutorials/android/ndk-tutorial/]Here[/url] is a good guide.[/QUOTE]
Thanks, ill have a look when it isnt approaching half 2 in the morning
I found out why SFML isn't working. Someone heading the Arch repository thought that SFML 2.0 was the one to use instead of SFML 1.6. I got the proper version and now I've got a different problem. Compiling goes proper, however I get this error at runtime:
[code]
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 1 (X_CreateWindow)
Serial number of failed request: 30
Current serial number in output stream: 32
[/code]
I'm starting a game studio with my friends. We have several games in development and would like to get our name out there. Do we need to register as a business or anything to use it? Is there anything we can do to prevent anyone else from taking that name?
Your name get's out there when you make something people want. So, until then you don't really need a name. Especially a legally recognized name. I would also note that often indie developers are known more as people rather than brand names.
And none of us are going to know about business law/strategy. Or at least very few (I'm thinking garry), which means you should ask them, not just drop a public notice in WDYNHW. You'd be better taking a class or asking a teacher or a friend or a friend of your parent's, or at the very least a forum for small businesses.
I was thinking about all of this as a lot of people here are developers. I just thought that maybe there were people here who have gone through this stage. Guess not though.
How would I go about handling a grid of a data type?
I know of arrays of arrays (int bleh[][]), but I have found that it gets complicated in the long run.
I just started using Python, and whenever I save a program in the idle, all the text turns black. Some of the stuff is usually orange, green, ect, depending on what I write.
Anyone know how to fix this? Or am I doing something wrong?
[QUOTE=Dryvnt;30490458]How would I go about handling a grid of a data type?
I know of arrays of arrays (int bleh[][]), but I have found that it gets complicated in the long run.[/QUOTE]
If that's C++, you can write a class for that.
Sadly C++ doesn't allow overloading the operator[] with multiple arguments, but you could create a get(x, y) function or misuse the operator().
I don't quite see what you mean by complicated though. The only thing that annoys me about that, is that it probably won't allocate in continuous memory.
If that's C, then there's still a small thing you can improve, that is using a one-dimensional vector, allocate width * height memory for it and access as vec[y * width + x].
operator()?
Wait, what?
[editline]16th June 2011[/editline]
Haha nobody ever told me operator() is overloadable :v:
I'm currently trying to make my tile-engine use a 10 piece tileset to make the tiles like this :
[img]http://i54.tinypic.com/bfgu50.png[/img]
So this is just done by hand but I need it to be done automaticly (for if a block is removed), the only way I could think of right now is just 10 if statements witch each 9 conditions in it (for each of the surrounding blocks) but that seems a bit messy. Is there a better way to do this ?
[QUOTE=quincy18;30492580]I'm currently trying to make my tile-engine use a 10 piece tileset to make the tiles like this :
[img]http://i54.tinypic.com/bfgu50.png[/img]
So this is just done by hand but I need it to be done automaticly (for if a block is removed), the only way I could think of right now is just 10 if statements witch each 9 conditions in it (for each of the surrounding blocks) but that seems a bit messy. Is there a better way to do this ?[/QUOTE]
I did it by having an enum like this:
[code]// BorderEnum
Right = 1
Bottom = 2
BottomRight = Right | Bottom // 3
Left = 4
LeftRight = Right | Left // 5
...
Top = 8
TopRight = Right | Top // 9
...[/code]
And so on, to show which sides of a solid tile are connected to an empty tile. Then all the pieces in the tileset are ordered to match this (the first one (0) is just solid wall, second (1) is a wall with a border to the right, the third (2) is a wall with a border to the bottom, etc).
Then I get the index to use in the tileset like this:
[code]Index :=
( TileToRight.IsSolid ? BorderEnum.Right : 0 ) |
( TileToBottom.IsSolid ? BorderEnum.Bottom : 0 ) |
( TileToLeft.IsSolid ? BorderEnum.Left : 0 ) |
( TileToTop.IsSolid ? BorderEnum.Top : 0 )[/code]
Sorry, you need to Log In to post a reply to this thread.