I'm currently programming a top down shooter, but I've got a problem. How to manage collision? I already have collision implemented but, it's not good enough. Sometimes, the ennemies succeed to through each others. The other problem I got, is that the collision responses are not fluid at all. i.e: ennemy1 collide with ennemy2, they get pushed too abruptly.
I manage my game like this:
1. Update the positions
2. Check the collisions ( Should I check the collisions just before updating the positions ? )
3. Draw the sprites
How can I proceed to get a good collision response ?
Edit:
I made some research on google, but each times I've seen answers about AABB, they explain how to know if two objects collide, but they never explain how to react to it. How can make it so they don't collide anymore.
using C# / XNA
I have a set of about 35 rooms, and want to randomly place them in a map...
[code]
0,0,1,0
0,2,3,1
2,3,0,0
0,1,0,0
[/code]
I was wondering how I would make a map like that.
0 represents no room, every other number represents a room.
All rooms need to connect.
I've coded in Python, Perl, and C++. I want to get into making small games, but I have no idea where to start. Would appreciate it if someone could point me in the right direction.
Get an input/drawing library/framework. Probably start with 2D if your goals include [i]actually finishing anything[/i]. I say this as someone who does not intend on ever finishing anything and chooses to dabble in 3D.
Popular choices are the LOVE2D framework for Lua, PyGame + Python, SDL + C, SFML + C++, XNA/OpenTK + C#, etc.
Choose one, make the 'stupid bouncing ball' introductory thing. Get some ideas. Download a sprite sheet. It should be straightforward from there, assuming you know how to program already.
[QUOTE=ROBO_DONUT;35518383]Get an input/drawing library/framework. Probably start with 2D if your goals include [i]actually finishing anything[/i]. I say this as someone who does not intend on ever finishing anything and chooses to dabble in 3D.
Popular choices are the LOVE2D framework for Lua, PyGame + Python, SDL + C, SFML + C++, XNA/OpenTK + C#, etc.
Choose one, make the 'stupid bouncing ball' introductory thing. Get some ideas. Download a sprite sheet. It should be straightforward from there, assuming you know how to program already.[/QUOTE]
thanks! I think I want to go the 2d route for starters like you suggested. how about allegro, is that a good library?
Does anyone have any idea what could be wrong with my lua loading function?
... got it working, i was missing:
if(luaL_loadfile(L, "./Settings") || lua_pcall(L, 0, 0, 0))
[QUOTE=Blackwheel;35518577]thanks! I think I want to go the 2d route for starters like you suggested. how about allegro, is that a good library?[/QUOTE]
I just learned C++ last week and started making a game in SFML 2.0. It is quite simple and nice.
The only downside is that most of the tutorials are for 1.6, so you'll need to translate those slightly - they won't work word-for-word in 2.0. However I like the design of 2.0 much more than 1.6.
[QUOTE=Loli;35518181]using C# / XNA I have a set of about 35 rooms, and want to randomly place them in a map... [code] 0,0,1,0 0,2,3,1 2,3,0,0 0,1,0,0 [/code] I was wondering how I would make a map like that. 0 represents no room, every other number represents a room. All rooms need to connect.[/QUOTE]
Off the top of my head, I'd do it recursively. Start with one room and pass the valid locations for additional adjacent rooms into the next call, either through the call or by appending them to some global array.
[QUOTE=Loli;35518181]using C# / XNA
I have a set of about 35 rooms, and want to randomly place them in a map...
[code]
0,0,1,0
0,2,3,1
2,3,0,0
0,1,0,0
[/code]
I was wondering how I would make a map like that.
0 represents no room, every other number represents a room.
All rooms need to connect.[/QUOTE]
If every room has (or has the possibility for) an entry\exit point at each of the four walls you can just generate a random number into each cell in the range 0 .. 35 - using whatever generator function you like (eg if you want to have one type of room generate less frequently than another). A couple of pitfalls with this technique are the Random Number God might decide to put rooms in stupid orders, and you're pretty much unable to get a specific pattern of rooms - say, rooms with ids "4 19 22" in a row - without a bit of work.
Alternatively, if some rooms can only be entered from some side, you could do this (I'd probably recommend this method, it lets you customise it more easily):
[QUOTE=CritDevelopment;35520851]Off the top of my head, I'd do it recursively. Start with one room and pass the valid locations for additional adjacent rooms into the next call, either through the call or by appending them to some global array.[/QUOTE]
Pick a random point to start, pick a random room, and put that room at that point. Then, for each direction that the room has doors, use that as the starting point and branch out from there; if there's an existing room in that direction, you abort. You can do this recursively, which might fail for absurdly large maps (but is easier) or you can make a "to process" list and put rooms into that as you generate them. As soon as you finish with the current room, take the next room out of the list and repeat from there. The main pitfall with this technique is that if you're unlucky, you could start on an edge and the first room you generate can only go outwards. You'll end up getting stuck, but you can fix this by clamping the coordinates of the starting room or regenerating the map until you achieve a minimum number of rooms.
Hmm, thanks for all the help. Each room can be entered from any direction, but I'll build a small console app to see how I could get it working. Also, the map size is clamped to a maximum of 32*32 rooms.
Thanks guys.
In other news, I'm free to give C# / XNA help to anyone who needs a hand.
Could anybody help me with 8086?
[QUOTE=Over-Run;35523350]Could anybody help me with 8086?[/QUOTE]
I [i]may[/i] be of some assistance, depending on what you need help with
[QUOTE=swift and shift;35523695]I [i]may[/i] be of some assistance, depending on what you need help with[/QUOTE]
Thanks a lot man, here is what I have to do: [url]http://pastebin.com/GwGJKa32[/url]
We did Assembly level programming last year and now we are doing a different one, last year we did 8086 I think sorry I got it confused. I need help with Mip64 programming.
Basically at that link provided, we have to implement that code into the Mip64 language, and once that is working that is 50% of the marks, the other 50% is optimizing it. Basically I just need help understanding the language, I was pretty good at 8086 but this language seems a lot more difficult.
Just not sure where to start with the assignment.
Could someone explain to me why/how this C-code works?
[code]
#include <stdio.h>
#include <stdlib.h>
int main()
{
char i;
for(i=0;i<12;i++)
printf("%c",i["asdf"]);
if(i["123"]==1)
i=1;
if(1["456"]==1)
i=1;
}[/code]
The console output is:
[code]
asdf 123[/code]
By using e.g. 1["asdf"] faulty (for example 1["asdf"]=1) the compiler quotes this expression as "asdf"[1] in the error message.
Even if these expressions are written that way, I don't understand why "123" is in the console output.
I sorted my project if anybody wants some code... It's shit, but it does the job and is only called once per game so... meh.
[QUOTE=Sari;35524837]Could someone explain to me why/how this C-code works?
[code]
#include <stdio.h>
#include <stdlib.h>
int main()
{
char i;
for(i=0;i<12;i++)
printf("%c",i["asdf"]);
if(i["123"]==1)
i=1;
if(1["456"]==1)
i=1;
}[/code]
The console output is:
[code]
asdf 123[/code]
By using e.g. 1["asdf"] faulty (for example 1["asdf"]=1) the compiler quotes this expression as "asdf"[1] in the error message.
Even if these expressions are written that way, I don't understand why "123" is in the console output.[/QUOTE]
You've raised a couple of points here. [i]Is 1["asdf"] equivalent to "asdf"[1], if so, why[/i] and [i]why is the output "asdf 123", with the 123 in particular[/i].
In C and C++, an array is effectively a pointer to the first element. When you find the second element, what actually takes place is pointer arithmetic. You take the address of the first object, and add one object length to it. This gives you the position of the next object in the array. So
[code]
int* startAddr[5]; // array of five integers, each 4 bytes so 20 bytes total
a[0] // pointer to first element, so startAddr + 0 objects = startAddr
a[1] // pointer to second element, so startAddr + 1 object = startAddr + 4 bytes
// that means these are equivalent
array[index] == index[array]
// because
array[index] = *(array + index) = *(index + array) = index[array];
[/code]
that should more or less solve your first question
your second one is why is the 123 showing up, it's showing up because you're looping from zero to 12 and printing out each of those characters. "asdf" is a const char* to some address in memory, and it seems like the "123" string immediately follows the "asdf" string in memory. as such when you go past the end of the "asdf" string you start reading the "123" string.
I hope this helps (ps i'm tired so stay tuned to other posters for corrections)
[QUOTE=mechanarchy;35525539]You've raised a couple of points here. [i]Is 1["asdf"] equivalent to "asdf"[1], if so, why[/i] and [i]why is the output "asdf 123", with the 123 in particular[/i].
In C and C++, an array is effectively a pointer to the first element. When you find the second element, what actually takes place is pointer arithmetic. You take the address of the first object, and add one object length to it. This gives you the position of the next object in the array. So
[code]
int* startAddr[5]; // array of five integers, each 4 bytes so 20 bytes total
a[0] // pointer to first element, so startAddr + 0 objects = startAddr
a[1] // pointer to second element, so startAddr + 1 object = startAddr + 4 bytes
// that means these are equivalent
array[index] == index[array]
// because
array[index] = *(array + index) = *(index + array) = index[array];
[/code]
that should more or less solve your first question
your second one is why is the 123 showing up, it's showing up because you're looping from zero to 12 and printing out each of those characters. "asdf" is a const char* to some address in memory, and it seems like the "123" string immediately follows the "asdf" string in memory. as such when you go past the end of the "asdf" string you start reading the "123" string.
I hope this helps (ps i'm tired so stay tuned to other posters for corrections)[/QUOTE]
Thanks for your explanation :)
If x[y] is equivalent to *(x+y), where is the usage of the datatype size?
Moreover I still don't get the thing with "123"...
It's obvious that this array follows "asdf" in the memory, but is there a sensefull reason for that? I mean, why should they belong together in any way? And why isn't that the case with "456" (resp. if i don't use a variable)
Whoa, nvm. i is not an immediate value. I'm going blind and I read it as '1'.
[QUOTE=Sari;35526092]Thanks for your explanation :)
If x[y] is equivalent to *(x+y), where is the usage of the datatype size? [/QUOTE]
I always believed that pointer arithmetics preserve alignment in a sense, ie. ptr + n really means ptr + n*sizeof(*ptr).
[QUOTE=esalaka;35526426]I always believed that pointer arithmetics preserve alignment in a sense, ie. ptr + n really means ptr + sizeof(*ptr).[/QUOTE]
Ok, that makes sense to me, thank you :)
Sorry to bother you with further questions, but I just noticed, that the program fails when I use this expression with different int variables as index:
[code]
int main()
{
int i;
int j;
for(i=0;i<3;i++)
printf("%c",i["asdf"]);
if(i["123"]==1)
i=1;
if("456"[j]==1)
i=1;
}[/code]
The program would even work if only j was a char. So why not this way?
I find it highly unlikely that '1' is ever going to equal 1, for instance. What exactly fails?
[QUOTE=esalaka;35527170]I find it highly unlikely that '1' is ever going to equal 1, for instance. What exactly fails?[/QUOTE]
I just wanted to use this String in any way, so I wrote this pointless equation.
There is no error from the compiler, just a windows error reporting when I run it.
Can someone tell me why in the if statement the first two strings don't appear until you input add1 + add2?
Sorry if my code sucks but I just started learning.
[code]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int PlayerResponse;
Console.WriteLine("Hello! welcome to simple calculator! please choose what you want.");
Console.WriteLine(" Add = 1 \n Subtract = 2 \n Multiply = 3 \n Divide = 4");
string OperationResponse = Console.ReadLine();
PlayerResponse = Convert.ToInt32(OperationResponse);
#region Add
string add1string = Console.ReadLine();
string add2string = Console.ReadLine();
int add1 = Convert.ToInt32(add1string);
int add2 = Convert.ToInt32(add2string);
#endregion
if (PlayerResponse == 1)
{
do
{
Console.WriteLine("Hello! This is the Adding function of the calculator!");
Console.WriteLine("Lets add numbers together");
Console.WriteLine(add1 + add2);
break;
}
while(PlayerResponse == 1);
}
}
}
}[/code]
For a light at a depth of z in eyespace, how do you go about scaling down the radius of the light so that it remains fixed width with respect to the geometry? (and assuming the light stops at the radius)
My normal perspective transformations go x (or y) * 700.0/depth, but this doesnt appear to work properly for the lighting for some reason
I'm working in Java, on a fighting game, and I want to enable all my weapons and items to have access to the character's stats and be able to alter them on the fly easily. Is there a way to do this with any sort of ease without ridiculous accessor / mutator methods?
I was thinking, since most of the stats are just integer values, I could return and receive arrays or objects of some sort, but would this work?
You could store the stats in your player class or make a new class for player stats that is stored in your player class. I'd probably choose the latter, and just have a couple of funcs to set/get a statistic type passed by parameter. You could access your stats through the player, or you could send it as a reference to a function in your weapon class.
[QUOTE=Ybbats;35533482]and just have a couple of funcs to set/get a statistic type passed by parameter.[/quote]
Explain this. So I have a generic method, like getStat(String attackpower) and it'll find the attackpower and return it? I more or less want the opposite, I want to accrue a lot of values across a lot of arbitrary files quickly without a lot of get and set statements.
[quote]You could access your stats through the player, or you could send it as a reference to a function in your weapon class.[/QUOTE]
Reference to a function? I don't understand your terminology. Sorry.
[QUOTE=Icedshot;35533066]For a light at a depth of z in eyespace, how do you go about scaling down the radius of the light so that it remains fixed width with respect to the geometry? (and assuming the light stops at the radius)
My normal perspective transformations go x (or y) * 700.0/depth, but this doesnt appear to work properly for the lighting for some reason[/QUOTE]
I think you've got your coordinate systems mixed up. 'eye-space' or 'view-space' is just like world-space, except that the origin is centered at the viewer, looking down the negative-Z axis. The transformation between view-space and world-space is just a simple translation and rotation. There is no scale, skew, or perspective involved.
Radius should be the same in both view-space and world-space.
You aren't trying to work in clip space (pre-perspective-division) or NDC/screen (post-perspective-division), are you? If you're working post-perspective-division, things get a little more complicated due to perspective distortion. Have this nifty leftover graphic I made for a post that I never wrote for a blog that I never made:
[t]http://i.imgur.com/Fyppw.png[/t]
You can try to correct for it with some trig, or you can just render an icosphere.
I've been trying to implement libCurl into a C++ program for a little while now (6+ hours), and can't get rid of linker errors:
[code]
1>libcurl.lib(connect.obj) : error LNK2019: unresolved external symbol _inet_pton referenced in function _bindlocal
1>libcurl.lib(curl_addrinfo.obj) : error LNK2001: unresolved external symbol _inet_pton
1>libcurl.lib(hostip4.obj) : error LNK2001: unresolved external symbol _inet_pton[/code]
I have compiled libcurl, and zlib from source with the proper settings (/Mt , static, x86) and both compile perfectly fine. However upon linking it in my actual program, it sends out those linker errors. All of the header files for inclusion are present for curl.
lib references:
[code]GWEN-Renderer-DirectX9.lib;gwen_static.lib;FreeImage.lib;opengl32.lib;wsock32.lib;ws2_32.lib;winmm.lib;libcurl.lib;%(AdditionalDependencies)[/code]
preprocessor:
[code]NDEBUG;USE_DEBUG_FONT;CURL_STATICLIB;%(PreprocessorDefinitions)[/code]
If you'd like to see the project (with the libcurl test and all) it is located here:
[url]https://github.com/pixellegacy/N8Update[/url] (Compile for Release only)
[QUOTE=HeroicPillow;35536200]curl stuff[/QUOTE]
Curl isn't compiled right, it's linked to _inet_pton as if it used the cdecl calling convention, but inet_pton is exported by ws2_32.dll with the stdcall convention.
Sorry, you need to Log In to post a reply to this thread.