1. Post #1
    Gold Member
    r4nk_'s Avatar
    April 2005
    2,006 Posts












    Yeah it was around when they switched diffuse to per-pixel that it started looking weird.

    I got bump-mapping to work too!



    Next up is specular mapping, which looks easy.
    I'm working on a software distribution system. It runs as a computer start-up script (over the logon screen) and installs any packages the computer needs. It all runs off a network share so there are no client side extensions at all.



    1. Get the workstation name
    2. Look in target.xml to find the computer's profile(s)
    3. Look in the profiles.xml file to find out what packages the profile has
    4. Look in the packages.xml file to find the install paths, friendly names and other settings for each package.
    5. Pass all the info back to the client which performs the checks and installs packages as necessary.

    Works fairly well other than it doesn't perform the actual file or registry checks yet so it will just loop reinstalling everything .
    Hmmmm. Something useful to say, that I'm working on. Hmmph, well, I've been rabbiting on about my logging library, and asking loads of C++ questions, so here is the (nearly) end result:
    http://dl.dropbox.com/u/234754/logger_charlie.7z
    (Apologies to anyone having the situation described by the log: I have a somewhat perverse sense of humour.)

    I'm quite proud of it, I guess. It's my first significant C++ project. I think it's got a fairly nice API, and the thing I think is really quite cool is that it has an output that supports templating (I wrote a lightweight templating "sublibrary" for this purpose). It includes a template that does outputs like this:

    If you think you have a use for it, by all means download it, but bear in mind it's not very tested, and doesn't have any exceptions support: if you supply it with an empty template file/one it can't find, it will give you a weird index error.

    If you know C++ at all, then you probably know it better than me, so if you could download it, and have a quick poke at the source, and suggest modifications/improvements to my code etc, that would very much be appreciated. If you want to contribute a new feature, especially one that's in a todo file, that would also be great! I will certainly do my best to critique any python code ( + possibly C#, although I'm not as good) you want done!

    The dependency locations within projects use relative paths, so as long as you have boost installed (even the header-only version is fine), you should be able to compile it.

    Next up, I want to write a fancy-schmancy javascript output option, that can filter results for faster lookups. I am also toying with the idea of writing a dedicated log file viewer application with wxWidgets, which could be a useful learning experience!

    If you want to know anything about how I've done anything (not that there's much interesting going on) feel free to ask!
    Terrain generator!


    white are normals, green are surfaces, red are stackables, can only put stackables on surfaces. Moving a surface with a stackable on it moves them both.
    oh dear



    I don't like rendertargets any more :eng99:
    The version 0.4 of my model format was totally fucked up...
    So i restructured the milkshape exporter plugin alot and now as you can seeeee, textured!
    That's the version 0.5.


    I just love Processing.


    It rotates depending on how you're holding your phone.

    BTW it works great on my Nexus One as well, its just easier to screenshot the emulator.
    Not content, but I couldn't stop laughing at this:


    KABOOMM

    Finally finished my particle editor, all needed configs/optimizations/features have been added and implemented them in my gamez.

    Also brkoen-lfet-hnad-ninja time !

    This thread needs more gifs

    I've added buildings and a basic character to control (from squidi.net)



    You can try it here: http://www.robertandsherman.co.uk/do...rpg_130310.zip


    Work in progress SPH fluid simulator. Looks more like goo at the moment, and it can be pretty unstable. Turned into more of an optimisation experiment than anything, I'll be implementing a uniform grid once I figure out how the hell to start.
    Little interactive demo without filters (current version has some pixel rounding issues) - http://filebox.me/view/mhu7ef7ht

    Xerios3, that looks awesome.


    Improving the autonomous of this robot. Yes, that is a soccer ball, it plays soccer.
    Got retriangulation of polygons done :D
    (For those who don't know: OpenglES only supports triangles, unlike 'full' Opengl which supports tri's quads and even polygons. My .obj loader now creates triangle strips when a face with more than 3 vertices are found)

    (418 triangles, runs _very_ smooth :D)
    Some more progress on my god game, I've added a few more UI elements including the world light/dark influence level and and an event system (you can see a building report underneath the resources).

    I've modelled some peasant characters but I'm a programmer and not a modeller so they've turned out pretty crappy :P

    Also I've gave every NPC in my game a unique name by filling two arrays with 100 forenames and 100 surnames giving me 10,000 combinations, so hopefully you'll never see the same name twice.

    I've also enabled the player to possess and unpossess NPCs on your side (in the screenshot I'm possessing Lewis Fisher). Basically as a god you can only traverse the land, use miracle powers and possess people. Possessing people hands over the control of an NPC to you and allows you to use all their skills and interact physically with the world.



    2nd Image showing possession about to happen:


    Still no luck with shadows yet :(
    Here's BeardMaster, where you shave the desired facial hair into the patient, so far it consists of one mustache level, it's in it's most basic form at the moment.

    http://spamtheweb.com/ul/upload/0603...eardshaver.php

    Edited:



    Style.
    I had an unexpected big error in my program today:





    I'm just working on some error handling at the moment and decided to give a little tribute to Valve's method of file/model not found exceptions. Looks like I underestimated the model scale a little, but it made me laugh.
    back. fucking with processing.

    trying to get this working with video, but every processing video library sucks big dongs.
    fractals are the new disco.
    dear god i have so much shit from old processing sketches that i'm surprised i've never posted.

    also, does anyone know how to get gifs to play at the proper speed in chrome?
    Well I thought after mainly lurking around here and merely posting stuff, I shall present one of my projects: ViruZ
    Please bear with me for a while, since there's quite some stuff to tell.

    The basic idea is that there are viruses (greenish circles) moving around and you can inject an anti-serum (blue stuff) with a mouse-click on the cursor position.
    The viruses will then get sick, stand still and have a contamination-radius, in which other viruses will get sick, too. After a short moment, they'll die by simply disappearing.
    Some viruses are resistant though and will be alive again after they've been sick.
    The aim is to kill a certain number of them each round with a limited amount of anti-serum.

    This is probably an abomination to any biological understanding, but I don't care since it's fun. It's still in alpha-stages: Viruses wander around, can get sick and will die and that's all there is apart from a FPS display, but like everything it'll just need time to grow. It is already fun to open it up, try to kill all viruses and doing it again.



    The FPS is quite low, because all rendering is performed on the CPU and it's vectorgraphics using cairo, which I have compiled by myself to use a bunch of VSs optimisation-flags and SSE2. My CPU is a Core2Duo E6600 (2x2.4GHz).
    The healthy and sick virus-graphics are prerendered and cached in a std::map<double radius, cairo_surface_t* gfx[NUM_SHARED_GFX_STATES]>. Zooming seems to be quite slow, so the build-up of the contamination-radius and the dying (which is displayed by shrinking into singularity) is rendered dynamically.
    cairos rendering backends seem to all be on the CPU (though I read that Mozilla is working on a Direct2D backend), so I'll be looking into using OpenGL to do the rendering of vector-graphic circles via simple pixel shaders.
    But I'm not too good at shaders yet. I will (hopefully) get though as I recently began to read a book about GLSL. I also have a book on OpenGL 3 in my shelf, but it's quite short and only scratches OpenGLs surface.

    I plan on having selectable power-ups and updates on your serum as you play, as well as tougher viruses and maybe different kinds, so they'll move differently, need different serums 'n stuff. atm I am just looking for something you can call a game, then I can still extend it.

    My current TODO is to make my gameloop more efficient. At the moment I have this:
    for each(virus) {
      virus.update(dt);
      while(!tryObtainingMutex()) {
        queue.push(virus);
        virus = next_virus;
        virus.update(dt);
      }
      queue.push(virus);
      //we have the mutex now
      for each(virus in queue)
        virus.draw();
      releaseMutex();
    }
    if(!queue.empty()) {
      obtainMutex();
      for each(virus in queue)
        virus.draw();
      releaseMutex();
    }
    But I want to look into having one thread drawing all updated viruses and having all the other available threads to update the viruses.

    Once I got this done, I'll be implementing resistant viruses and the ability to read in levels from a file (I actually have a level-system implemented already,it simply uses hard-coded values).
    Then onto a proper HUD in the lower part of the window, showing some states like amount of healthy viruses and then I need a finite state machiene to switch the game states (menu, in-game, ...), implement a basic main-menu and this is the point when I want to release a public alpha.

    Progress is a bit slow atm, because I'm close to my Abitur exams.

    Currently it's only for Windows, but I want to port it to Unix-systems at some point when I care about fixing my MBR to use GRUB again... damn Windows overriding it.
    It should be portable code, apart from the window-creation and input-handling. I'm using the WinAPI to do that, all the other classes and functions rely on standard C++, cairo and OpenMP. And ciaro will hopefully be replaced by OpenGL 3 some when.

    Before releasing I'll also have to read through the licenses of those libs.
    I plan to release the source code after I'm finished under either the GPL or the zlib. Both philosophies have their appeal.
    Still working on "GridWorld2"

    A whole bunch of bugs eating flowers and avoiding rocks. In a real-time environment, not step based like GridWorld. You can spawn various actors and call methods on them just like in GridWorld, too.
    I'm working on a RPG engine in Flash. My goal for this is to have an RPG I am happy with where most of the game is randomly generated (within reason).

    I wrote a new resource loading system which works fine. It uses text files like this:
    Code:
    "font"
    {	name			image path
    	"default"		"font_default.png"													;
    	"large"			"font_large.png"													;
    }
    
    "frame"
    {
    	"default"		"frame_default.png"	"3"			"3"									;
    	"border"		"frame_border.png"	"5"			"5"									;
    }
    
    "anim"
    {
    	"ui_loadwhirl"		"loadwhirl_#.png"				"0"			"8"				"4"			;
    	"ui_char_select"	"char_select_#.png"				"0"			"2"				"16"		;
    	
    	"misc_mg_cat"		"mg_cat_#.png"					"0"			"4"				"4"			;
    }
    I'm writing a map generator now. So far I have it outputting stuff like this:


    (the black lines are cliffs)

    What I want to do now is have it placing a road network, but I can't think of a good way to do it. It needs to go around most of the map, but not be the same basic layout each time a map is generated. Also, it needs to connect to somewhere on each of the 4 sides on the map.

    Can any of you think of a good way of doing this?
    Currently working on a C++ school project.
    I call it Swine Flu Snake, would be to boring to make the original snake.
    No i haven't done the 2D engine by myself, I'm using HGE (sort of like SDL).

    Menu


    Collisions?


    Bullets


    Sure, the game works but it still needs some tweaking.
    Using an Excel table, I tweaked the constants in my algorithm to give more satisfactory results. It's still nowhere near perfect, but the results are quite good as demonstrated by another two random images from Google:




    Is anyone interested in the source code or method used?


    Got a lot of work done since I've taken that screenshot, I'm now working on a way to load entities through a map file.
    Added a few more things to my game today, reworked some of the lighting and added some new UI elements.

    I'm having trouble with shadows in Ogre though, when an object is intersecting with the ground it casts its shadow incorrectly and in multiple directions so they're disabled for now till I find out what's wrong.

    I've also got construction half implemented now, you get a ghost preview appearing in front of your character and you can rotate it before deciding on placement, you can choose which building from the pop-out menu at the bottom (just houses for now):



    Here's a copy-paste of the description:
    I got it!

    I was using the wrong type of logarithm for the normalization(e, when I should've been using 2).






    Well, thanks for trying to help.





    ...Now to get a better color scheme, simple controls, and maybe some supersampling...


    Edited:
    Note: This one is still wrong, I fixed it up since posting this, but won't change the picture because I'm fucking lazy.










    Version 8

    Version 7

    Version 6

    Version 5

    Version 4

    Version 3

    Version 2

    Version 1




    So...WHAT ARE YOU WORKING ON?
    Reply With Quote Edit / Delete Australia Show Events Friendly Friendly x 10Artistic Artistic x 2 (list)

  2. Post #2
    www.bff-hab.de
    Dennab
    February 2009
    7,832 Posts
    I never make it into highlights :(
    Reply With Quote Edit / Delete Germany Show Events Friendly Friendly x 18Funny Funny x 1Agree Agree x 1Dumb Dumb x 1 (list)

  3. Post #3
    Neigh
    CarlBooth's Avatar
    June 2007
    24,669 Posts
    Great OP, well done.

    (Woo! Made it twice :D)
    Reply With Quote Edit / Delete United Kingdom Show Events Friendly Friendly x 1Optimistic Optimistic x 1 (list)

  4. Post #4
    Gold Member
    Vampired's Avatar
    February 2005
    371 Posts
    Reply With Quote Edit / Delete Show Events Agree Agree x 14Funny Funny x 5 (list)

  5. Post #5
    Gold Member
    Dlaor's Avatar
    June 2007
    4,994 Posts
    Reply With Quote Edit / Delete Netherlands Show Events Agree Agree x 2 (list)

  6. Post #6
    Turd92's Avatar
    March 2008
    182 Posts
    Hey guys check out my boxes.


    :3:

    Now that I've got Box2D and SFML playing nice, I can get to the fun stuff.

    Edited:

    Oh yeah and nice thread.
    Reply With Quote Edit / Delete United Kingdom Show Events Dumb x 11Optimistic x 2Funny x 1Useful x 1Friendly x 1 (list)

  7. Post #7
    Gold Member
    Dlaor's Avatar
    June 2007
    4,994 Posts

    Am I doing it right?
    Reply With Quote Edit / Delete Netherlands Show Events Agree Agree x 24 (list)

  8. Post #8
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    Another reason to hate Java. You can't choose to pass things by value or reference. All primitives are by value and all other objects are by reference. So to do anything in my srcsrv project I had to pass a String[] and use [0] as the string instead of just being able to pass by reference in C++ &String.

    :sigh:

    Thanks Java.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 4 (list)

  9. Post #9
    BOSSMAN
    leontodd's Avatar
    January 2009
    4,062 Posts

    Am I doing it right?
    Haha, good one.
    Reply With Quote Edit / Delete United Kingdom Show Events Agree Agree x 1Dumb Dumb x 1 (list)

  10. Post #10
    Gold Member
    ryandaniels's Avatar
    December 2006
    3,809 Posts


    My grapher with the a function for the top half of a circle, it's derivative, and it's derivative (worked by hand, not automatically).

    And here's the whole circle for fun, not really mathematically relevant.



    The code turned out pretty messy, not sure how much of that was my fault, and how much was the innate complexity of handling all the exceptions that come with parsing this kind of text.
    Reply With Quote Edit / Delete United States Show Events

  11. Post #11
    Gold Member
    Ortzinator's Avatar
    May 2005
    1,645 Posts
    Well since you used an old crappy version of my planet renderer, I figured I'd better post the latest version. Now with better atmosphere.


    Reply With Quote Edit / Delete United States Show Events Artistic Artistic x 11 (list)

  12. Post #12
    Gold Member
    ryandaniels's Avatar
    December 2006
    3,809 Posts
    snip
    Reply With Quote Edit / Delete United States Show Events

  13. Post #13
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    Another reason to hate Java. You can't choose to pass things by value or reference. All primitives are by value and all other objects are by reference. So to do anything in my srcsrv project I had to pass a String[] and use [0] as the string instead of just being able to pass by reference in C++ &String.

    :sigh:

    Thanks Java.
    I'm no expert on Java, but if it does indeed not give you any control, you could make a class for the output of the function:
    DoStuffResult result = new DoStuffResult();
    doStuff(result);
    //use properties of result
    

    If that isn't your problem, I do think you have a different problem with your code, passing an array doesn't sound like the best solution.
    Reply With Quote Edit / Delete Norway Show Events

  14. Post #14
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    I'm no expert on Java, but if it does indeed not give you any control, you could make a class for the output of the function:
    DoStuffResult result = new DoStuffResult();
    doStuff(result);
    //use properties of result
    

    If that isn't your problem, I do think you have a different problem with your code, passing an array doesn't sound like the best solution.
    You have to pass an array because that's the only way you'd be able to pass by reference in Java because an array is an Object in Java -- unlike the String (which technically isn't a primitive but it's immutable) -- and I need to be able to edit the value in other functions.
    Reply With Quote Edit / Delete United States Show Events

  15. Post #15
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    You have to pass an array because that's the only way you'd be able to pass by reference in Java because an array is an Object in Java -- unlike the String (which technically isn't a primitive but it's immutable) -- and I need to be able to edit the value in other functions.
    Class types are Object's too. There's no reason to use an array when all you're gonna do is keep a single reference to an immutable string in it. And are you sure you're doing this right? Why can't they just return the edited string? They're immutable for a reason, it's not like you're truly mutating the string in the array, you're just creating a new string with different content and putting a reference to the new string at the first index.

    edit:

    And if you truly are doing something like low level performance critical string manipulation; maybe use a char[] instead and convert it to a string when it's gone through all the processing?
    Reply With Quote Edit / Delete Norway Show Events Useful Useful x 1 (list)

  16. Post #16
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    I'm sure that I could just return the edited string, but that would mean more processing on my part and more code. Using a character array could possible make more sense, but then I'd have to work with indexes in an array vs length of a string. But I suppose that at the end of the day, it's all about choosing your evil. :P

    This is one of the functions that edits the string:
    Code:
    	private byte getByte(String[] serverInformation){
    		if(this.hasBytes(serverInformation)){
    			byte returnByte = (byte) serverInformation[0].charAt(0);
    			serverInformation[0] = serverInformation[0].substring(1);
    			return returnByte;
    		} else {
    			return 0x00;
    		}
    	}
    ^ That's the only reason that I use an array is that I can edit it. :\

    Edited:

    At least when I port it over into C#, I'll be able to pass by reference and do as I please. I just find it mildly humorous that you can't choose to do so in Java by the ampersands operator.
    Reply With Quote Edit / Delete United States Show Events

  17. Post #17
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    The problem is your choice of data-type. You don't want a string, you may not even want an array of characters, more like an array of bytes. The whole point of your serverInformation string is to mutate it; don't use an immutable type.

    Using a character array could possible make more sense, but then I'd have to work with indexes in an array vs length of a string. But I suppose that at the end of the day, it's all about choosing your evil. :P
    Indexes in an array vs length of a string? You're using charAt, which is equivalent of indexing an array of characters. Arrays also contain the length of the array, just like String's do.

    At least when I port it over into C#, I'll be able to pass by reference and do as I please. I just find it mildly humorous that you can't choose to do so in Java by the ampersands operator.
    Strings are immutable in C# too, though, at the end of the day your solution is just as bad in C#.
    Reply With Quote Edit / Delete Norway Show Events Agree Agree x 1 (list)

  18. Post #18
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    Yes, that was very of me. I'll probably just rewrite it and use a byte array like it started with from receiving the query results. Hell, that'd be a lot easier.
    Reply With Quote Edit / Delete United States Show Events Friendly Friendly x 1 (list)

  19. Post #19
    Gold Member
    Dlaor's Avatar
    June 2007
    4,994 Posts
    Working on various methods of scattering a picture.
    Reply With Quote Edit / Delete Netherlands Show Events Artistic Artistic x 9 (list)

  20. Post #20
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    I looked for information on it, but it looks like the notion of array slicing is completely foreign in Java. The only suggested solution seems to be System.arraycopy...

    At least in C#, you get ArraySegment.
    Reply With Quote Edit / Delete Norway Show Events

  21. Post #21
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    I looked for information on it, but it looks like the notion of array slicing is completely foreign in Java. The only suggested solution seems to be System.arraycopy...

    At least in C#, you get ArraySegment.
    Yeah, you have to manually remove the indexes. and it still doesn't like you editing byte arrays by reference.

    Code:
    	private byte[] removeIndex(byte[] serverInformation, int indexLength){
    		byte[] returnArray = new byte[serverInformation.length - indexLength];
    		for(int x = indexLength; x < serverInformation.length; x++){
    			returnArray[x - indexLength] = serverInformation[x];
    		}
    		return returnArray;
    	}
    Reply With Quote Edit / Delete United States Show Events

  22. Post #22
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    Yeah, you have to manually remove the indexes. and it still doesn't like you editing byte arrays by reference.

    Code:
    	private byte[] removeIndex(byte[] serverInformation, int indexLength){
    		byte[] returnArray = new byte[serverInformation.length - indexLength];
    		for(int x = indexLength; x < serverInformation.length; x++){
    			returnArray[x - indexLength] = serverInformation[x];
    		}
    		return returnArray;
    	}
    What are you trying to do? What does the client code look like for all these functions? I'm sure there's a better way if I only understood the big picture.
    Reply With Quote Edit / Delete Norway Show Events

  23. Post #23
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    What are you trying to do? What does the client code look like for all these functions? I'm sure there's a better way if I only understood the big picture.
    I have a function called getByte() which gets 1 byte from the byte array and removes the first index. In that case, I'd use that function to remove 1 index of the array. However, the problem that I'm running into is that it won't let me pass a byte array to a function and edit it in the function. I tried that in the function I posted above and it won't change the actual values except in the function's instance.

    So, I basically tried this:
    Code:
    	private void removeIndex(byte[] serverInformation, int indexLength){
    		byte[] returnArray = new byte[serverInformation.length - indexLength];
    		for(int x = indexLength; x < serverInformation.length; x++){
    			returnArray[x - indexLength] = serverInformation[x];
    		}
    		serverInformation = returnArray;
    	}
    If you want to see the entire 'idea' of the program and the functions that I have, look at the older version that I posted in What are you working on? Version 8 :
    http://www.facepunch.com/showpost.ph...postcount=1962
    Reply With Quote Edit / Delete United States Show Events

  24. Post #24
    hOnK :o)
    i300's Avatar
    December 2009
    3,985 Posts
    More pixels :3:

    It scrolls too.

    (Download)
    Reply With Quote Edit / Delete United States Show Events Artistic Artistic x 1 (list)

  25. Post #25
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    I have a function called getByte() which gets 1 byte from the byte array and removes the first index. In that case, I'd use that function to remove 1 index of the array. However, the problem that I'm running into is that it won't let me pass a byte array to a function and edit it in the function. I tried that in the function I posted above and it won't change the actual values except in the function's instance.

    So, I basically tried this:
    -snip-

    If you want to see the entire 'idea' of the program and the functions that I have, look at the older version that I posted in What are you working on? Version 8 :
    http://www.facepunch.com/showpost.ph...postcount=1962
    The problem is that you're basically using a stack of bytes for the server information when it could just be a fixed size buffer throughout the parsing process.

    Keep the whole buffer as a private field the whole time, also keep track of the current parsing position. That way your get functions could look like this:
    class ServerInformation
    {
    	private byte[] data; //assign this
    	private int curIndex = 0;
    
    	/*
    		-snipped code-
    	*/
    
    	private byte getByte(){
    		if(curIndex == data.length()){
    			throw new ParseErrorException("Packet contains bad information"); //Please convert to idiomatic Java
    		}
    		return data[curIndex++];
    	}
    
    	/*
    		There ought to be more efficient ways to do this even in Java,
    		perhaps use System.arraycopy to a char[] buffer then convert that
    		to a string.
    	*/
    	private String getString(){
    		String ret = "";
    		byte b;
    		while((b = getByte()) != 0x00){
    			ret += (char)b;
    		}
    		return ret;
    	}
    
    	/*
    		This ByteBuffer is interesting, perhaps you should use it for all the
    		get functions.
    	*/
    	private short getShort(){
    		ByteBuffer byteBuffer = ByteBuffer.allocate(2);
    		byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
    		byteBuffer.put(getByte());
    		byteBuffer.put(getByte());
    		return byteBuffer.getShort(0);
    	}
    }

    I don't know Java, but I know for sure there are better ways to handle memory here. You should look into the ByteBuffer class.
    Reply With Quote Edit / Delete Norway Show Events

  26. Post #26
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    I was happily surprised when I found the ByteBuffer class. :P

    Edited:

    Oh, and I'll rewrite my class to use byte[] when I get home from work. :3:

    Edited:

    Aye, well, I had a few minutes and I was fucking around, and I found that I wasn't able to change an array to another array because you can't "re-set-set" an array. So, you'd have to do this, if anyone was wondering:

    	private void removeIndex(byte[] serverInformation, int indexLength){
    		byte[] returnArray = new byte[serverInformation.length - indexLength];
    		for(int x = indexLength; x < serverInformation.length; x++){
    			returnArray[x - indexLength] = serverInformation[x];
    		}
    		System.arraycopy(returnArray, 0, serverInformation, 0, returnArray.length);
    	}
    
    Reply With Quote Edit / Delete United States Show Events

  27. Post #27
    Gold Member
    Dlaor's Avatar
    June 2007
    4,994 Posts
    This is starting to look like Minecraft
    Reply With Quote Edit / Delete Netherlands Show Events Artistic Artistic x 9Funny Funny x 1Optimistic Optimistic x 1 (list)

  28. Post #28
    Gold Member
    Zaldos's Avatar
    April 2010
    296 Posts
    A little bit.
    Reply With Quote Edit / Delete United Kingdom Show Events Disagree Disagree x 1 (list)

  29. Post #29
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    Still fucking awesome.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 1 (list)

  30. Post #30
    hOnK :o)
    i300's Avatar
    December 2009
    3,985 Posts
    Nice. Minecraft is a very fucking good game.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 7Disagree Disagree x 1 (list)

  31. Post #31
    Gold Member
    nullsquared's Avatar
    November 2007
    2,450 Posts
    Reposting the code segment:
    Code:
    // return index of element or -1 if not found
    int binarySearch(int arr[], int n)
    {
        int start = 0, end = arr.length - 1;
    
        while (start <= end)
        {
            int mid = (start + end) / 2;
            if (arr[mid] == n) return mid;
            else if (mid == start && mid == end) break;
            if (arr[mid] < n) start = mid + 1;
            else end = mid - 1;
        }
    
        return -1;
    }
    Replies:
    bean_xp posted:
    Sorry misread.

    For arrays with even size, the last item is never tested?
    You're completely right, actually; I can't believe I made that bug. You actually need to check if mid == start AND mid == end (or just mid == end because of how integer division works). However, this wasn't the extremely subtle bug I'm talking about, and I've fixed it in the above code segment.

    Assume that the bug still exists! Also, assume that it is a technical bug - you may assume that the logic of the binary search is correct (now it definitely should be after that fix).

    mechanarchy posted:
    .. plus you skip out a bunch of logic stuff in the while loop so it'd end up being faster... wouldn't it?
    No. What you have shown is a search with O(n) complexity, where a binary search has O(logn) complexity. VERY different. (but the binary search has a precondition: the list must be sorted)
    Reply With Quote Edit / Delete United States Show Events

  32. Post #32
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    -snip-
    Reply With Quote Edit / Delete Norway Show Events

  33. Post #33
    Gold Member
    nullsquared's Avatar
    November 2007
    2,450 Posts
    Nono, we mean if start=0 and end=1, then mid=0. And the check is if start=mid, which means that the element at end will never get tested. So we need to do if start=mid=end, which would be false, meaning the search will continue. (not || but &&)

    Also, the problem is still open like I said, disregard this bug as it is now fixed.
    Reply With Quote Edit / Delete United States Show Events

  34. Post #34
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,600 Posts
    Nono, we mean if start=0 and end=1, then mid=0. And the check is if start=mid, which means that the element at end will never get tested. So we need to do if start=mid=end, which would be false, meaning the search will continue. (not || but &&)

    Also, the problem is still open like I said, disregard this bug as it is now fixed.
    Yeah, I jumped to a quick conclusion because of the way you decided to compare the start and end to mid.
    Reply With Quote Edit / Delete Norway Show Events

  35. Post #35
    majorlazer's Avatar
    February 2010
    232 Posts
    Nice. Minecraft is a very fucking good game.
    no not really.
    Reply With Quote Edit / Delete Canada Show Events Disagree Disagree x 8Agree Agree x 1 (list)

  36. Post #36
    hOnK :o)
    i300's Avatar
    December 2009
    3,985 Posts
    no not really.
    Thats your opinion.
    I find it very fucking good.
    Reply With Quote Edit / Delete United States Show Events Informative Informative x 1Agree Agree x 1 (list)

  37. Post #37
    www.bff-hab.de
    Dennab
    February 2009
    7,832 Posts
    Here is a better place to discuss Minecraft

    Also, it's nice for artsy people who just want to build castles, but boring for me as I want gameplay.
    Reply With Quote Edit / Delete Germany Show Events

  38. Post #38
    Gold Member
    Loli's Avatar
    April 2008
    2,263 Posts
    Working on a chat client for my school...
    I hate it how they block everything students like.
    Pictures to come soon
    Reply With Quote Edit / Delete United Kingdom Show Events

  39. Post #39
    hOnK :o)
    i300's Avatar
    December 2009
    3,985 Posts
    Here is a better place to discuss Minecraft

    Also, it's nice for artsy people who just want to build castles, but boring for me as I want gameplay.
    This will be my last word on Minecraft here, but if you buy the game and go to the development version there is crafting, monsters, day/night, etc. Lots of great gameplay.

    Now back on topic.
    I made another pixel-y thing with SDL.

    I cannot explain this. Ahh I love programming! :woop:

    (Download)

    By the way I recommend downloading these because they usually have color changing and shit. Thanks!
    Reply With Quote Edit / Delete United States Show Events Dumb Dumb x 1 (list)

  40. Post #40
    Gold Member
    nullsquared's Avatar
    November 2007
    2,450 Posts
    Another reason to hate Java. You can't choose to pass things by value or reference. All primitives are by value and all other objects are by reference. So to do anything in my srcsrv project I had to pass a String[] and use [0] as the string instead of just being able to pass by reference in C++ &String.

    :sigh:

    Thanks Java.
    Just a quick terminology note: *everything* is passed by value. Including the references. Meaning you can modify the object that the reference "refers" to, but you can't modify the passed in reference itself because it's passed by value.

    Kind of like this in C++:
    Code:
    void foo(int *p)
    {
        *p = 5; // we can modify the actual object
        p = NULL; // but not the actual passed in reference, since we get a copy of it
    }
    
    int *x = new int;
    foo(x);
    // x is NOT null
    Same in Java, except no * syntax. Fortunately in C++ you can add a '&' right after that star, making it a reference to a pointer, and then x would infact be NULL after calling foo.
    Reply With Quote Edit / Delete United States Show Events