[QUOTE=Coffeee;42831170]What would be the best type of program to make to show off my skills to a college?[/QUOTE]
Whatever type of program you're best at creating.
[QUOTE=mobrockers;42831384]Whatever type of program you're best at creating.[/QUOTE]
What specifically?
[QUOTE=Coffeee;42831515]What specifically?[/QUOTE]
You're the only one that can answer that question.
Whatever you're best at making will best show them what you're capable of.
How do you go about getting something before a Token in a JSON string?
For example, I have this JSON string:
{"status":"okay","result":{"id":34,"country":"US","region":"MD","city":"Baltimore","latitude":39.2904,"longitude":-76.6122,"comment":"987595 monkeys"}}
I can get everything from ID onwards as I provide result as the JToken.
However, I need to get the status field too, but I can't figure out how to?
Here is the code I have so far:
[CODE] JObject jobj = JObject.Parse(jsonString);
JToken jstatus = jobj["status"];
JToken jresult = jobj["result"];
status = (String)jstatus["status"];
id = (String) jresult["id"];
country = (String)jresult["country"];
region = (String)jresult["region"];
city = (String)jresult["city"];
latitude = (String)jresult["latitude"];
longitude = (String)jresult["longitude"];
comment = (String)jresult["comment"];[/CODE]
[code]status = (String)jstatus;[/code]
?
This is why I don't deserve to be doing a Computer Science course.
Thanks man
Anyone familiar with Prolog? I'm trying to write a postorder traversal for trees.
An example would be
[code] ?- postorder(a(b,c,d(e,f,g))).
b c e f g d a
[/code]
The best I can come up with is
[code]postorder([], []).
postorder(tree(X, L, R), List) :-
postorder(L, LL),
postorder(R, RL),
append(LL, RL, List1),
append(List1, [X], List).[/code]
The problem is my predicate takes 2 parameters instead of 1 and it also doesn't work.
Anyone can point me in the right direction for collision detection between objects that are only one pixel?
I'm currently making a particle sandbox and I was wondering what the right way to go is for the collision.
I thought about box collision between them but that's pretty heavy for what are essentially just particles.
AFAIK most particle sandboxes use an underlying grid with discrete motion and a very simplified physics model.
E.g. each step a particle tries to moves down one square and randomly tries to moves left/right a certain amount of squares.
When doing a web request, I need to wait until it gets a response before continuing, otherwise it seems it keeps jumping into code I need the response to do.
Here is the code:
[code]
async public Task<string> GetInformation(string url)
{
var client = new HttpClient();
var response = await client.GetAsync(new Uri(url));
result = await response.Content.ReadAsStringAsync();
return result;
}
async public Task<string> GetResult(string url)
{
await GetInformation(url);
return result;
}
[/code]
It seems when response is used, it breaks.
How can I fix this?
Anyone who knows BNF?
I'm supposed to derive the function call "print()" in Python 3, but I'm really lost here... I've got no idea where to go after:
[code]
stmt => simple_stmt => (expr_stmt?)
[/code]
The grammar is at [url]http://docs.python.org/3/reference/grammar.html[/url] if anyone who understands this type of stuff would care to have a look..
[QUOTE=Over-Run;42841419]When doing a web request, I need to wait until it gets a response before continuing, otherwise it seems it keeps jumping into code I need the response to do.
Here is the code:
[code]
async public Task<string> GetInformation(string url)
{
var client = new HttpClient();
var response = await client.GetAsync(new Uri(url));
result = await response.Content.ReadAsStringAsync();
return result;
}
async public Task<string> GetResult(string url)
{
await GetInformation(url);
return result;
}
[/code]
It seems when response is used, it breaks.
How can I fix this?[/QUOTE]
Breaks how? An exception?
[QUOTE=FalconKrunch;42838891]Anyone can point me in the right direction for collision detection between objects that are only one pixel?
I'm currently making a particle sandbox and I was wondering what the right way to go is for the collision.
I thought about box collision between them but that's pretty heavy for what are essentially just particles.[/QUOTE]
If you run into issues, there are probably some open source falling sand games you can take a look at.
[QUOTE=ZeekyHBomb;42841703]Breaks how? An exception?
If you run into issues, there are probably some open source falling sand games you can take a look at.[/QUOTE]
It's fine I ended up fixing it.
Needed to make all of the methods async and all
[QUOTE=karl1k;42841644]Anyone who knows BNF?
I'm supposed to derive the function call "print()" in Python 3, but I'm really lost here... I've got no idea where to go after:
[code]
stmt => simple_stmt => (expr_stmt?)
[/code]
The grammar is at [url]http://docs.python.org/3/reference/grammar.html[/url] if anyone who understands this type of stuff would care to have a look..[/QUOTE]
It seems you continue with expr_stmt, like you assumed, and go on to testlist_star_expr => test => or_test => and_test ... and you should find it from here :)
[QUOTE=ZeekyHBomb;42841842]It seems you continue with expr_stmt, like you assumed, and go on to testlist_star_expr => test => or_test => and_test ... and you should find it from here :)[/QUOTE]
Thanks, didn't expect it to be that deep, haha.
Does this parse tree look correct to you(right side)? I'm not sure whether the print and parantheses should be split like that, feels wrong
[IMG]http://i.imgur.com/S1OCacv.png[/IMG]
[editline]12th November 2013[/editline]
Oh, and uh, sorry about the long picture..
The trailer should probably expand to '(' ')', although it is a minor detail.
Otherwise, that seems how you'd expand "print()". It does look weird to have to go through all those unrelated non-terminals, but I guess this is done to make the grammar unambiguous.
[QUOTE=ZeekyHBomb;42842449]The trailer should probably expand to '(' ')', although it is a minor detail.
Otherwise, that seems how you'd expand "print()". It does look weird to have to go through all those unrelated non-terminals, but I guess this is done to make the grammar unambiguous.[/QUOTE]
Yeah, I wasn't sure whether I should put '()' or '(' ')' but I think you're right. Thanks a lot for the help!
[QUOTE=Larikang;42840523]AFAIK most particle sandboxes use an underlying grid with discrete motion and a very simplified physics model.
E.g. each step a particle tries to moves down one square and randomly tries to moves left/right a certain amount of squares.[/QUOTE]
most falling sand games(where I can find the source from) just check the pixels, I'd like to do a bit more complicated stuff if I can, so I tried to stay away from evaluating pixels.
I guess I can just do the old AABB collision for the moment, though it'll probably completely kill performance when you have a few thousand onscreen at the same time.
For my FYP I need to allow for a displacement to be applied to the position of the camera.
This is so that I can have one instance using position, and another using position + displacement in order to render from both points nd get 3d.
To do this im just passing in a float, but I wasnt sure how I could apply this to the position by creating a vec3 with x displacement.
So basically:
[code]
void MatrixManager::SetDisplacement( float displacement )
{
mDisplacement = displacement;
glm::vec3 displMatrix(mDisplacement, 0.0f, 0.0f);
mView = glm::lookAt( mPosition + displMatrix, mLookAt, mUp );
mViewOrthographic = mViewOrthographic * mView;
mViewPerspective = mPerspective * mView;
}[/code]
But surelly I would need to rotate it somehow or else it would be fine when both are aligned but when rotated the placement of both would become unaligned?
I think this image shows what im trying to explain better
[IMG]http://i.imgur.com/TxAa1Z8.png[/IMG]
Did anyone had experience with Borland TASM debugger? I want to ask if I could make the window larger since looking into a 80x25 char window is a pain. what I need is if I can force it to use bigger char resolution i.e. 120x60 chars.
or should I give up since that shit was hardcoded back in the day? also I didnt saw any other configs but seems that Dosbox only offers window scaling.
Okay so I need some help parsing a JSON string array.
I have already made it so it can parse one City Object using the id and country etc, and I would like to be able to go through the array and add each one to a List, which can be used to show a ListView in a Windows 8 app.
So for example, I have this JSON data:
[URL]http://honey.computing.dcu.ie/city/cities.php?id=34&cn=ie[/URL]
And I would like List<Cities> where each element is a different city.
Here is the code I have so far and I have made no progress.
[URL]http://pastebin.com/K91Kf3vw[/URL]
[QUOTE=Over-Run;42844902]Okay so I need some help parsing a JSON string array.
I have already made it so it can parse one City Object using the id and country etc, and I would like to be able to go through the array and add each one to a List, which can be used to show a ListView in a Windows 8 app.
So for example, I have this JSON data:
[url]http://honey.computing.dcu.ie/city/cities.php?id=34&cn=ie[/url]
And I would like List<Cities> where each element is a different city.
Here is the code I have so far and I have made no progress.
[url]http://honey.computing.dcu.ie/city/cities.php?id=34&cn=ie[/url][/QUOTE]
I'm not sure which part you're stuck at, nor which language you're working with. All you're showing us is some JSON data.
[QUOTE=mobrockers;42845056]I'm not sure which part you're stuck at, nor which language you're working with. All you're showing us is some JSON data.[/QUOTE]
Whoops sorry I pasted the wrong bit.
Also working with C#
I updated it there with my code.
Basically the problem is that the JSON data I get doesn't start with [ like its mean't to.
The ones I get always start like this:
{"status":"okay","result":[{"id":8810,"country":"IE","region":"07","city":"Dublin","latitude":53.3331,"longitude":-6.2489,"comment":"824593 donkeys"},
So I need to get the status seperately I think.
Basically I want to have a list of Cities, and in that Cities I want each City to be represented by ID, Country, Region, City, Latitude, Longitude & Comment.
I just can't figure out how to parse the arrays since it doesn't start with [ and most examples I find online assume the JSON data starts with that.
[QUOTE=Richy19;42844256]For my FYP I need to allow for a displacement to be applied to the position of the camera.
This is so that I can have one instance using position, and another using position + displacement in order to render from both points nd get 3d.
To do this im just passing in a float, but I wasnt sure how I could apply this to the position by creating a vec3 with x displacement.
So basically:
[code]
void MatrixManager::SetDisplacement( float displacement )
{
mDisplacement = displacement;
glm::vec3 displMatrix(mDisplacement, 0.0f, 0.0f);
mView = glm::lookAt( mPosition + displMatrix, mLookAt, mUp );
mViewOrthographic = mViewOrthographic * mView;
mViewPerspective = mPerspective * mView;
}[/code]
But surelly I would need to rotate it somehow or else it would be fine when both are aligned but when rotated the placement of both would become unaligned?
I think this image shows what im trying to explain better
[IMG]http://i.imgur.com/TxAa1Z8.png[/IMG][/QUOTE]
Just had an idea for this, if I compute the left of my current position using the cross of my direction and up, then times left by the amount of displacement then add that to the position, that should do it right?
so it would look like:
[code]
glm::vec3 left = glm::cross( glm::normalize(mLookAt - mPosition), mUp );
glm::vec3 newPos = mPosition + (left * mDisplacement);
mView = glm::lookAt( newPos, mLookAt, mUp );
[/code]
That would work right?
how do you guys do platformer physics / collision logic effectively?
my implementation involves multiple rectangles placed around the body, similar to the method discussed here ([url]http://games.greggman.com/game/programming_m_c__kids/[/url]). However I'm almost sure that this isn't the most optimal way to do this.
[QUOTE=Shotgunz;42845595]how do you guys do platformer physics / collision logic effectively?
my implementation involves multiple rectangles placed around the body, similar to the method discussed here ([url]http://games.greggman.com/game/programming_m_c__kids/[/url]). However I'm almost sure that this isn't the most optimal way to do this.[/QUOTE]
Do a broad phase by using spatial hashing to detect which objects can collide. This will improve performance immensely.
Then do some narrow phase using bounding boxes.
To resolve a collision never resolve it on both axis at the same time!
Always do it like this:
- find the t (time) when the collision happened
- find out which direction/axis you should resolve (use the one that has the smallest overlap)
- move the moving object back on this axis and set its velocity on that axis to zero
- move the object with the new velocity for the remaining time of the frame
Maybe I worded the last step a bit confusing.
What I mean is that now that the objects collision is handled you're not done. If you'd stop here your objects would not be able to "glide" up/down a wall or move along the ground.
In the first step you determined at what fraction between the last and current frame your collision happened. Now you need to continue moving the object for the remaining fraction because most of the time objects will have velocity on the x AND the y axis.
For example the player collides with a wall (while jumping). Then you set his X velocity to zero because he collided, but retain the Y velocity.
Does anyone here ever organize their code with flowcharts? My grandfather was telling me that when he used to write programs for old machines (like, with punch cards and shit), he'd have to draw up flowcharts with flowchart stencils so he could keep track of what the programs did.
I ask because I'm trying to find ways to organize my workflow and make better habits, but I don't know where to start.
How do I open a html page in a Java GUI? The html file will be saved on my computer.
[QUOTE=aurum481;42844342]Did anyone had experience with Borland TASM debugger? I want to ask if I could make the window larger since looking into a 80x25 char window is a pain. what I need is if I can force it to use bigger char resolution i.e. 120x60 chars.
or should I give up since that shit was hardcoded back in the day? also I didnt saw any other configs but seems that Dosbox only offers window scaling.[/QUOTE]
Try [url=http://devtidbits.com/2008/03/16/dosbox-graphic-and-machine-emulation-cga-vga-tandy-pcjr-hercules/#comment-312]this[/url].
[QUOTE=Foxtrot200;42846056]Does anyone here ever organize their code with flowcharts? My grandfather was telling me that when he used to write programs for old machines (like, with punch cards and shit), he'd have to draw up flowcharts with flowchart stencils so he could keep track of what the programs did.
I ask because I'm trying to find ways to organize my workflow and make better habits, but I don't know where to start.[/QUOTE]
There's a standardized language called UML.
I have yet to meet someone who actually likes drawing these graphs, short of school teachers and the occasional university professor.
[QUOTE=wlitsots;42846743]How do I open a html page in a Java GUI? The html file will be saved on my computer.[/QUOTE]
Look at [url=http://docs.oracle.com/javafx/2/overview/jfxpub-overview.htm]JavaFX[/url].
[QUOTE=Over-Run;42844902]Okay so I need some help parsing a JSON string array.
I have already made it so it can parse one City Object using the id and country etc, and I would like to be able to go through the array and add each one to a List, which can be used to show a ListView in a Windows 8 app.
So for example, I have this JSON data:
[URL]http://honey.computing.dcu.ie/city/cities.php?id=34&cn=ie[/URL]
And I would like List<Cities> where each element is a different city.
Here is the code I have so far and I have made no progress.
[URL]http://pastebin.com/K91Kf3vw[/URL][/QUOTE]
Since you're already using Json.NET, why don't you make your life easier and do something like [url=https://gist.github.com/OrfeasZ/7a7508c7129f00a1e45f]this[/url]?
Sorry, you need to Log In to post a reply to this thread.