Jump to content

  • Log In with Google      Sign In   
  • Create Account

MarkS

Member Since 09 Jan 2001
Offline Last Active Today, 09:09 PM

#5293874 Breaking out of a nested loop

Posted by MarkS on 27 May 2016 - 04:24 PM

you have to set j back to zero tho else it does the job. Also this is how assembly would work


Oh crap! :unsure:




#5293863 Breaking out of a nested loop

Posted by MarkS on 27 May 2016 - 02:53 PM

Just replace the for loops with if goto pairs so that goto won't look so lonely.


So...
 

int i = 0, j = 0;
    loop:
        if(i - 1 == j + 1)
            goto outer;
    ++j;
    if(j < 10)
        goto loop;
    j = 0;
    ++i;
    if(i < 10)
        goto loop;

outer:

Seems pretty clean to me!

[edit] Fixed glaringly obvious and embarrassing mistake...




#5286132 Yo dawg, I herd u liek gd.net

Posted by MarkS on 10 April 2016 - 08:36 AM

I'm going to don my tinfoil hat and say that that wasn't made by any administrator here...




#5264126 Looking for a free 2D engine

Posted by MarkS on 29 November 2015 - 11:35 AM

I haven't used it, but Godot Engine looks quite powerful and it's free.


#5262077 Member function pointers?

Posted by MarkS on 14 November 2015 - 09:24 PM

If you use C++11 onward, you  should use std::function and combine it with std::bind.

class AnotherObject
{
public:
   std::function<void(void)> callback;
};

class TestObject
{
public:
   void MyFunction() {};
};

int main()
{
   AnotherObject ao;
   ao.callback = std::bind(&TestObject::MyFunction, &ao);
   ao.callback();
}





#5261217 How hard it is to live from games as indie developer?

Posted by MarkS on 09 November 2015 - 03:26 PM

I remember reading an article written by the lead programmer of an indie project on iOS. His project (not a game) was an overnight sensation with over 10,000 downloads. The amount of money he made through those sales totaled something like $300 USD.
 
I wish I kept the link!sad.png


#5260936 Connecting to SQL Server

Posted by MarkS on 07 November 2015 - 03:55 PM

Please quit posting the same thing over and over. The servers are having difficulty at the moment. Give it time to update.


#5260343 bmp Loader class

Posted by MarkS on 03 November 2015 - 11:36 AM

What I do for storing images/textures is keeping them in a format of my own. Of course, that's probably not useful to you but, why not post it?


To add to what Alundra said...

You start by making up a header format. It doesn't have to be long or complicated:
image_width : 4 bytes
image_height : 4 bytes
bytes_per_pixel : 1 byte
In code, it would be:
struct image_header{
long image_width;
long image_height;
char bytes_per_pixel;
};
To write the file, you write out the correct number of bytes for each header field and then the image data from your buffer. I prefer not to make assumptions about integer size and thus header size. "long" may or may not be 4 bytes, depending in the platform, but can be guaranteed to be no less than four bytes. Always explicitly write out the correct number of bytes per field and never rely on "sizeof(image_header)" when reading the file. On some 64-bit systems, "long" might be 8 bytes, in which case reading or writing "sizeof(long)" will not get you what you expect.

Reading is the reverse of writing.


#5259998 How do I re-size a binary file?

Posted by MarkS on 01 November 2015 - 10:24 AM

Why are you trying to resize "Batman Arkham Asylum" assets?


That is interesting...


#5259949 bmp Loader class

Posted by MarkS on 31 October 2015 - 07:15 PM

Yes bmp sucks but I feel so close. This code works perfectly with bmp only one flaw when I try to free the pixels I get heap corruption. !!! 
The only reason I use this format because I dont want to overload my head with compression and decompression, as I understand and correct me if am wrong everything else including targa uses compression.


Compression is optional in TGA files. I've never used it.


#5259910 bmp Loader class

Posted by MarkS on 31 October 2015 - 02:09 PM

There is also DevIL to consider.




#5259895 bmp Loader class

Posted by MarkS on 31 October 2015 - 11:24 AM

First off, I wouldn't recommend using BMP as a texture storage and loading format. Ideally, you'd create your own format, but barring that, I'd use TGA. It is far easier to load as the format just makes sense. BMP is highly screwed up, as you've noticed. The pixels are not stored as you would expect. Padding *may* be added per scanline, which makes looking at the file with a hex editor all but useless.

 

If you are insistent on using BMP, do some studying:

 

https://en.wikipedia.org/wiki/BMP_file_format

http://www.fileformat.info/format/bmp/egff.htm

http://paulbourke.net/dataformats/bmp/

 

It is not a programmer-friendly format.




#5259811 How to get angle for 360 degrees for a line

Posted by MarkS on 30 October 2015 - 05:15 PM

I'll let Dijkstra answer: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html


Well, yes, such as it applies to computers and programming. I was thinking about how math is taught in school.


#5259628 Confused at rotating an object around a transformed circle

Posted by MarkS on 29 October 2015 - 03:12 PM

You need to scale your object radius in the Update function by the same amount you scale the path.

Changing this:
obj[i].y				= obj[i].radius * Math.sin(angle);
To this:

obj[i].y				= (obj[i].radius * 0.3) * Math.sin(angle);
Fixed the problem.


#5259366 Game development with assembly. Where to start?

Posted by MarkS on 27 October 2015 - 10:18 PM

Hello,
 
For the past few days I have been learning assembly and I was wondering how to display graphics on the screen.
 
I'm doing this just for fun because I feel like I'm starting to burn out on my main game project and I thought I would do something fun like learn assembly. However displaying text on a console wasn't very exciting for me. So I'm taking it to the next level.
 
So, does anyone know how to start game development with assembly?
 
thanks happy.png


Why do you want to do this? What do you hope to gain? Yes, there is still the ability to write optimized assembly, but you can write just as optimized code and write it far quicker in a higher level language with today's compilers. I certainly recommend learning assembly, but for no other reason than to know what is going on behind the scenes. It's a step up from writing code directly in binary. It's like learning how to fix an engine to get your driver's license.




PARTNERS