Okay, I am going to get a shit-ton of flak for using Game Maker but its a really small project for engineering.
How would I get an object to start out spawning slightly off screen, go to a random X coordinate, and have it do this over and over while causing more and more to spawn as time goes on?
If you guys have alternate game making utilities that would also be fine
Thanks
I need to split a an input into seperate words and then check them against a dictionary imported from a file, and it's working fine aside from the translation messing up after punctuation.
The offending bit of code:
[code] string value;
string input = rtxInput.Text;
int word = 0;
string[] tweetWords = input.Split(' ');
string[] wordsForLookup = input.ToUpper().Split(' ',',', '.', '!', '?', '(', ')','/');
for (int i = 0; i < tweetWords.Length; i++)
{
if (textDictionary.TryGetValue(wordsForLookup[word], out value))
{
rtxOutput.Text = (rtxOutput.Text + " " + textDictionary[wordsForLookup[i]]);
}
else
{
rtxOutput.Text = (rtxOutput.Text + " " + tweetWords[i]);
}
word++;
}[/code]
As far as I can tell this is because the two arrays split on different characters so their keys aren't matching.
So "lol yeah! brb lmao" is translated as "Laughing out loud yeah! brb Be right back" because the arrays are [1,lol] [2,yeah] [3,brb] [4,lmao] for the words for translation and [1,lol] [2,yeah] [3,] [4,brb] [5,lmao] so "" is being translated for brb and everything is horribly offset from there.
C# by the way.
In short, how do I split on the first seperator in a pair but not the second, or another way of handling this problem?
why does AddBox make my android application stop?
[cpp]
int count = 0;
class box
{
int x;
int y;
} private box[] boxes;
public void AddBox(int x, int y)
{
boxes = new box[1];
boxes[count].x = x;
boxes[count].y = y;
count++;
}
[/cpp]
[QUOTE=rute;35328726]why does AddBox make my android application stop?[/QUOTE]
Never mind.
Does that happen first time you call it?
I have a question about memory leaks, do I have to delete an instance if I use a pointer that is only going to point at said instance? Does it count as a memory leak?
[QUOTE=mutated;35325274]What's a good way to set up file structure in Java? I can create packages just fine, which organizes all my class files, but I'd prefer to split source files into folders so I can look at them much more easily - I have a lot of files and I intend to add more.[/QUOTE]
I've always used subpackages.
For example, if my project is packaged as net.calzoneman.MyProject, I would have my workspace set up with the following packages:
net.calzoneman.MyProject.gfx
net.calzoneman.MyProject.input
net.calzoneman.MyProject.entity
...
I think that's how most Java developers do it, I might be wrong though.
It seems that I'm asking too much, but whatever...
Is it bad if I leave a bug in the code and work on something else while I can't fix that bug?
[code]
private static Rectangle c=new Rectangle(0,0,0,0);
static ArrayList<Rectangle> clipStack=new ArrayList<Rectangle>();
public static void pushClip(Graphics g, float x, float y, float w, float h){
clipStack.add(new Rectangle(x,y,w,h));
if(x + w < c.getX() + c.getWidth() )
c.setWidth(w);
if(y + h < c.getY() + c.getHeight() )
c.setHeight(h);
if(x>c.getX())
c.setX(x);
if(y>c.getY())
c.setY(x);
g.setWorldClip(c);
}
public static void popClip(Graphics g){
Rectangle o=clipStack.remove(clipStack.size()-1);
if(o.getX() + o.getWidth() > c.getX() + c.getWidth()) c.setWidth(o.getWidth());
if(o.getY() + o.getHeight() > c.getY() + c.getHeight()) c.setHeight(o.getHeight());
if(o.getX() < c.getX()) c.setX(o.getX());
if(o.getY() < c.getY()) c.setY(o.getY());
g.setWorldClip(c);
}
[/code]
Thats my clipping code, and
[code]
public void render(Graphics g){
if(isVisible()){
Vec2 worldPos=getWorldPos();
Util.pushClip(g, worldPos.x,worldPos.y,getWidth(),getHeight());
g.pushTransform();
g.translate(pos.x,pos.y);
draw(g);
for(int I=children.size()-1;I>=0;I--){
Panel pan=children.get(I);
if(pan==this){
continue;//noo
}
pan.render(g);
}
g.popTransform();
Util.popClip(g);
}
}
[/code]
is the code that uses it, but it causes clipping to get all weird and barely work
[QUOTE=ichiman94;35329657]It seems that I'm asking too much, but whatever...
Is it bad if I leave a bug in the code and work on something else while I can't fix that bug?[/QUOTE]
I'd say it depends on how more complex your code becomes when working on "something" and how related it is to the bug.
Personally I would fix the bug before moving on.
[QUOTE=ichiman94;35329657]It seems that I'm asking too much, but whatever...
Is it bad if I leave a bug in the code and work on something else while I can't fix that bug?[/QUOTE]
That depends on the bug.
[QUOTE=Cassel;35328780]
I have a question about memory leaks, do I have to delete an instance if I use a pointer that is only going to point at said instance? Does it count as a memory leak?[/QUOTE]
No. Only things allocated with new/malloc() need to be deleted. Observing pointers will not leak.
[QUOTE=Cassel;35330075]I'd say it depends on how more complex your code becomes when working on "something" and how related it is to the bug.
Personally I would fix the bug before moving on.[/QUOTE]
Basically I'm stuck with collisions, not with the detecting, but the handling of them. "something" doesn't relates to the bug, I just wanted to work on inventory and weapons [B]after[/B] the collision handling, but if I have to fix it, then I can't make progress on the game yet, as currently I don't know how to fix it.
I don't know if it has been asked before so sorry if it has.
Does anyone know any good resources for socket programming (UDP) in C++?
I have good experience both with C++ and networking in general. Just never worked with sockets in C++.
It is for a bigger school project (a multiplayer game) and I'm not too keen on having to get a third party library for multiple reasons. I'd also appreciate if it was cross-platform, but it's not a must as long as it's Windows.
I have tried to google it for it myself, but I couldn't find any really good ones.
Every platform (including Windows) uses some form of Berkeley sockets or BSD sockets.
The API is mostly the same.
Probably a stupid question, but:
I have a class called RomanNumeral in RomanNumeral.cpp, and am including RomanNumeral.h in my main.cpp, but I'm getting this error [code]Error 1 error LNK2019: unresolved external symbol "public: __thiscall RomanNumeral::RomanNumeral(void)" (??0RomanNumeral@@QAE@XZ) referenced in function _main C:\Documents\Projects\romanNumeralConverter\romanNumeralConverter\main.obj romanNumeralConverter[/code]
I'm using Visual Studio 2010 Ultimate.
EDIT: Fixed. I forgot to implement the default constructor function. Silly me.
[QUOTE=ROBO_DONUT;35331174]Every platform (including Windows) uses some form of Berkeley sockets or BSD sockets.[/QUOTE]
Berkeley sockets, of course, being the same thing as Berkeley Software Distribution sockets.
[QUOTE=ichiman94;35330945]Basically I'm stuck with collisions, not with the detecting, but the handling of them. "something" doesn't relates to the bug, I just wanted to work on inventory and weapons [B]after[/B] the collision handling, but if I have to fix it, then I can't make progress on the game yet, as currently I don't know how to fix it.[/QUOTE]
Depending on what you're doing, this might help: [url]http://facepunch.com/threads/1167392?p=35216367&viewfull=1#post35216367[/url]
So I'm trying to send Warcraft III ingame chat messages via a C# program. The packet to send a chat message to the host is [URL="http://www.bnetdocs.org/?op=packet&pid=465"]here[/URL]. I don't understand a lot about networking though. For example, what is the message ID? I played a match of Warcraft with Wireshark running in the background but the chat packet didn't look like the format in the link I posted before. The message was there, but in between some odd characters. I feel like I'm in over my head. Could someone please post an explanation of this, and perhaps some guide so I can understand networking better?
Well I basically figured out my problem, took a lot of googling but I think I almost have it.
[code]from sys import argv
script, file1 = argv
f = open(file1, 'r+')
r = f.read()
thelist = [x.strip() for x in r.split('\t\n')]
print 'Recategorizing your file.'
f.truncate()
for item in thelist:
f.write(item + ';\n')
f.close()
def main():
return 0
if __name__ == '__main__':
main()
[/code]
The only problem is it writes the re-categorized list under the sloppy list I have in the txt file. For whatever reason I can't truncate the original list so the text file only contains the new list.
most of the lists look like this
[code] firstname lastname
firstname lastname
firstname lastname
[/code]
just much much larger and the output is
firstname lastname;
firstname lastname;
firstname lastname;
If it helps, if i throw a 0 in truncate i get these before my new list starts.
[code]\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00[/code]
I gotta make a simple website with about 3ish pages for an assignment, I got a cheat list of html codes and stuff, where's a good place to start learning/following tutorials on building a site?
[QUOTE=Novangel;35341079]I gotta make a simple website with about 3ish pages for an assignment, I got a cheat list of html codes and stuff, where's a good place to start learning/following tutorials on building a site?[/QUOTE]
I would recommend some sort of IDE. I use Visual Web Developer Express because it's free and my copy of Frontpage was getting pretty old. When you need an html element or attribute, just google search it, and if you want a more comprehensive guide you should visit [url=www.w3schools.com]w3 schools[/url] which has great guides on any aspect of web development you might need.
Nevermind, found a shitty site that's really helpful with basics, this is no gigantic 50 pages website, this is just a minimum 3 pages website assignment thing :v:
I'm trying to draw outlined polygons in OpenGL.
My approach to this is by using two triangles each to make a number of rectangles. From here, I render these rectangles with a glPolygonOffset(1.f, 1.f) to make the outline, then clear the polygon offset and render the rectangles again in a different colour. This produces nearly the desired effect, however the outlines formed do not meet at perfect corners. Is there any easy way I can rectify this?
The effect can be seen here:
[img]http://dl.dropbox.com/u/6929441/screenshots/helium-06.png[/img]
(If I render the map with glPolygonOffset(1.f, -1.f), you can see the actual [url=http://dl.dropbox.com/u/6929441/screenshots/helium-06a.png]geometry of the scene[/url])
The code I am using to render the main part of the map is as follows:
[cpp]
//
// Render the black outlines
//
ShaderProg->Uniform3f("vertColour", Vector3f(0.f, 0.f, 0.f));
glPolygonOffset(1.f, 1.f);
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(1.0f);
// Draw the batch
Map_.GetBatch().Draw();
// Unfuck everything
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_POLYGON_OFFSET_LINE);
//
// Render the white filled-in parts
//
ShaderProg->Uniform3f("vertColour", Vector3f(1.f, 1.f, 1.f));
Map_.GetBatch().Draw();
[/cpp]
In XNA, i have a texture. How can i calculate the position of a certain pixel in the texure even if the texture is rotated?
[QUOTE=Rayjingstorm;35341671]I would recommend some sort of IDE. I use Visual Web Developer Express because it's free and my copy of Frontpage was getting pretty old. When you need an html element or attribute, just google search it, and if you want a more comprehensive guide you should visit [url=www.w3schools.com]w3 schools[/url] which has great guides on any aspect of web development you might need.[/QUOTE]
Well done sir.
You might also want to notice that most of the time a text editor with syntax highlighting suffices (vim is godtier for anything but that's just my opinion) and that W3Schools is not only not affiliated with W3C, it also contains a number of errors, as rather aggressively shown [url=http://w3fools.com/]here[/url].
The alternative they seem to suggest is [url=https://developer.mozilla.org/en-US/docs]Mozilla Doc Center[/url] which I recall is quite nice.
[editline]29th March 2012[/editline]
Of course, I don't think the MDC offers any tutorials per se
Is having a base class for all the things I am working with bad? And say class A uses class B extensivly, but they are both allocated on the heap. Would it be bad to have a pointer in class A to class B? Like an instance of class B, so B *? So instead of having to add the B * argument to most functions, I could just use the pointer.
Could you use a reference?
If not, just put a nice pointer in there. Preferably a STL "smart" pointer class assuming you're doing C++.
A reference would still mean adding countless arguments for no real reason.
Could you have a reference to the object as a class member, I meant.
[QUOTE=mechanarchy;35342940]I'm trying to draw outlined polygons in OpenGL.
My approach to this is by using two triangles each to make a number of rectangles. From here, I render these rectangles with a glPolygonOffset(1.f, 1.f) to make the outline, then clear the polygon offset and render the rectangles again in a different colour. This produces nearly the desired effect, however the outlines formed do not meet at perfect corners. Is there any easy way I can rectify this?
The effect can be seen here:
[img]http://dl.dropbox.com/u/6929441/screenshots/helium-06.png[/img]
(If I render the map with glPolygonOffset(1.f, -1.f), you can see the actual [url=http://dl.dropbox.com/u/6929441/screenshots/helium-06a.png]geometry of the scene[/url])
The code I am using to render the main part of the map is as follows:
[cpp]
//
// Render the black outlines
//
ShaderProg->Uniform3f("vertColour", Vector3f(0.f, 0.f, 0.f));
glPolygonOffset(1.f, 1.f);
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(1.0f);
// Draw the batch
Map_.GetBatch().Draw();
// Unfuck everything
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_POLYGON_OFFSET_LINE);
//
// Render the white filled-in parts
//
ShaderProg->Uniform3f("vertColour", Vector3f(1.f, 1.f, 1.f));
Map_.GetBatch().Draw();
[/cpp][/QUOTE]
Draw actual lines, instead?
GL_LINE_LOOP will get you an outline around the polygon.
[QUOTE=esalaka;35348363]Could you have a reference to the object as a class member, I meant.[/QUOTE]
Oh, yeah I guess. What would be the difference though?
Sorry, you need to Log In to post a reply to this thread.