• What Are You Working On? V13
    5,003 replies, posted
[QUOTE=Richy19;26036385]Just finishing a great birthday :D, not sure if I can bother to code on my game today. Screw it, anyone have some good resources on collision detection in C++? I am also using SFML if that matters[/QUOTE] november? [img]http://75.101.147.23/image.php?u=95045&dateline=1278976918[/img]:hf:[img]http://75.101.147.23/image.php?u=293850&dateline=1280167965[/img] Happy birthday.
[QUOTE=Richy19;26036385]Just finishing a great birthday :D, not sure if I can bother to code on my game today. Screw it, anyone have some good resources on collision detection in C++? I am also using SFML if that matters[/QUOTE] Well what you can do is maintain a list of rectangles and iterate though them checking the bounds, it may not lend it's self to dynamic physics but it gets pretty close with some modifying.
[QUOTE=Richy19;26036385]Just finishing a great birthday :D, not sure if I can bother to code on my game today. Screw it, anyone have some good resources on collision detection in C++? I am also using SFML if that matters[/QUOTE] [url]http://www.gamedev.net/reference/list.asp?categoryid=45#199[/url]
[QUOTE=Vbits;26037206]Search all your files for any write operations, also some of your arrays could be a little too big.[/QUOTE] The problem is I'm not just linearly writing to the stream, I'm jumping all over the place.
[QUOTE=Robert64;26038314]The problem is I'm not just linearly writing to the stream, I'm jumping all over the place.[/QUOTE] What is the value of the char\byte and what does it represent?
[QUOTE=Robber;26037270]Bliss n Eso - Addicted[/QUOTE] Thank you very much!
[QUOTE=Richy19;26036385]Screw it, anyone have some good resources on collision detection in C++? I am also using SFML if that matters[/QUOTE] I'd also appreciate a good 2D collision tutorial. C# preferred but pseudo code is fine or even just the best logic to apply behind it.
If you are using XNA then there is Rectangle.Intersects(Rectangle)
[QUOTE=Vbits;26038447]What is the value of the char\byte and what does it represent?[/QUOTE] It's always a 0, just a phantom byte that appears from nowhere. There is literally nothing writing it as far as I can tell. Had to solve it with: [csharp]byte STUPID_CHEATING_HACK = stream.ReadByte();[/csharp]
Have you checked your array sizes.
[QUOTE=Vbits;26038707]If you are using XNA then there is Rectangle.Intersects(Rectangle)[/QUOTE] That doesn't work reliably with fast moving small objects hitting other small objects.
[QUOTE=Vbits;26038775]Have you checked your array sizes.[/QUOTE] Not sure what you mean. Which arrays?
How are you writing into the file?
[QUOTE=Vbits;26039100]How are you writing into the file?[/QUOTE] BinaryWriter on top of a FileStream.
[QUOTE=Robert64;26038754]It's always a 0, just a phantom byte that appears from nowhere. There is literally nothing writing it as far as I can tell. Had to solve it with: [csharp]byte STUPID_CHEATING_HACK = stream.ReadByte();[/csharp][/QUOTE] Maybe you're just writing the terminating byte of a string or something?
[QUOTE=ZeekyHBomb;26036032]Did you already implement Lua-scripting? If so, could you post the code of one of the gates? I'd specifically be interested in the indicator, since it changes its appearance, and some gate that has an output.[/QUOTE] Im working on the lua to make custom gates, [url=http://pastebin.com/X4f0VN7d]code for indicator[/url], once i have lua done, il proberly move everygate to lua, due it would become more easy to add more gates beocuse of all the examples what do you mean whit a filesystem? (my thinking of this is having a listview once the lua is done, so you can sort your custom gates by placing the lua files in a sepcific folder path "lua/customgates/int/pi.lua" as example) il inplant the pause/resume button! and hopefully i wil come up whit an idea to make multi select... Thanks for the sugestions!
[QUOTE=esalaka;26039208]Maybe you're just writing the terminating byte of a string or something?[/QUOTE] I never write strings.
[QUOTE=neos300;26036462]I just realized a cell is exactly like a computer. The nucleus is the processor (DNA is the ROM?) vacuole is the RAM/HDD, mitochondria/chloroplasts are the batteries/PSU/solar panels, the ribosomes/ER are little wires and data, and the cell wall/membrane is the case.[/QUOTE] [url]http://ds9a.nl/amazing-dna/[/url]
[QUOTE=Robert64;26039282]I never write strings.[/QUOTE] Show some code?
[QUOTE=CarlBooth;26038686]I'd also appreciate a good 2D collision tutorial. C# preferred but pseudo code is fine or even just the best logic to apply behind it.[/QUOTE] If your using XNA this is the best way to do it [url]http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Coll_Detection_Overview.php[/url]
[QUOTE=high;26039440]Show some code?[/QUOTE] Well the main problem is: [csharp]public void Save( BinaryWriter stream ) { stream.Write( GetEntID( this ) ); long lengPos = stream.BaseStream.Position; // Mystery byte appears here only if this is an inventory item stream.Write(( ushort ) 65535 ); // Will be overwritten long startPos = stream.BaseStream.Position; SaveInternal( stream ); long endPos = stream.BaseStream.Position; stream.BaseStream.Seek( lengPos, SeekOrigin.Begin ); stream.Write(( ushort )( endPos - startPos )); stream.BaseStream.Seek( endPos, SeekOrigin.Begin ); }[/csharp] This is in the base Entity class, and works when saving everything except inventory items. [editline]13th November 2010[/editline] As you can see I write a ushort at one point, then after the entity has saved it goes back and writes how many bytes were saved by the entity at that position. This is where the mystery byte appears, after the first thing written and before the second.
[QUOTE=CarlBooth;26038686]I'd also appreciate a good 2D collision tutorial. C# preferred but pseudo code is fine or even just the best logic to apply behind it.[/QUOTE] Still [url]http://www.gamedev.net/reference/list.asp?categoryid=45#199[/url] damnit
[QUOTE=Robert64;26039499]Well the main problem is: -Code- This is in the base Entity class, and works when saving everything except inventory items. [editline]13th November 2010[/editline] As you can see I write a ushort at one point, then after the entity has saved it goes back and writes how many bytes were saved by the entity at that position. This is where the mystery byte appears, after the first thing written and before the second.[/QUOTE] A ushort is 16bits in length, how many hex characters does each data set weigh.
[QUOTE=Vbits;26039848]A ushort is 16bits in length, how many hex characters does each data set weigh.[/QUOTE] Well up to 4 I guess. I know the sizes of each numeric type.
what is the inventory size.
I'd advise that you step over it in the debugger and then find out which line is adding said byte. Look at this for how to read the contents of a stream in the debugger: [url]http://stackoverflow.com/questions/830408/how-to-inspect-xml-streams-from-the-debugger-in-visual-studio-2003[/url] (Not sure if the current versions of VisualStudio allow you to easily get the contents of stream. Also not sure if it will affect the current position of the stream or not - Worth a try though.) [b]Edit:[/b] Just tried it, it does work however it also changes the position of the stream. You could always do the following though: [cpp]long CurrentPosition = stream.BaseStream.Position; stream.BaseStream.Position = CurrentPosition;// Put breakpoint here, use a "quick watch" to see its content, then continue stepping on[/cpp] Add these between every write line and inspect the content at each location.
What does the SaveInternal look like between a Item in the inventory and another entity.
[QUOTE=Robber;26039017]That doesn't work reliably with fast moving small objects hitting other small objects.[/QUOTE] Wut?
[QUOTE=BlkDucky;26040565]Wut?[/QUOTE] The code that powers that very function [csharp] public bool Intersects(Rectangle value) { return ((((value.X < (this.X + this.Width)) && (this.X < (value.X + value.Width))) && (value.Y < (this.Y + this.Height))) && (this.Y < (value.Y + value.Height))); } [/csharp] Though looking at the code it should work fine on fast moving objects, if not enlighten me.
You need some form of CCD (continuous collision detection) to work with fast moving bodies, or small bodies. The problem is that they can over-penetrate a body in a single time-step so you have to cast their movement forwards between the previous and new positions in order to make sure that doesn't happen.
Sorry, you need to Log In to post a reply to this thread.