Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
quick question 4 C programmers
#51
Quote:You're right, my biggest QBasic program is over 1000 lines, and at times it seems to be getting a bit complex. When things start getting out-of-hand, I usually create a new SUB and chuck a whole section in. Don't know if that will work if it reaches the 10000 line mark!
The key is encaspulation. When you place sections of code in a function, you're encapsulating that code, and abstracting it's execution. Looking at InitGameObjects(), it's easier to see what your code is doing, rather than sifting through 100's of lines of init code. That abstraction allows you a clearer picture of your bird's-eye view. Other major encapsulation techniques like using multiple modules, each with their own responsibility, start coming in to play. If you've got one module that is 10,000LOC, you need to do some serious refactoring. Smile

OO is similar, except that instead of algorithmic sections, you typically organize your code in objects, and define how those objects interact with each other.
stylin:
Reply
#52
Quote:I tend to do i like this, its just a re-write of code I found all over the web. Excuse if its filth, its old.

Code:
unsigned long YF_Window_ResizeClientArea(HWND Window_hWnd, unsigned long NewClientWidth, unsigned long NewClientHeight)
{
  RECT r1;
  RECT r2;

    /* get window dimensions and position */
    if (!GetWindowRect(Window_hWnd, &r1)) return 0;
    if (!GetClientRect(Window_hWnd, &r2)) return 0;  

    /* calculate new size based on difference between r1 and r2 and call MoveWindow */
    if (!MoveWindow(Window_hWnd, r1.left, r1.top, NewClientWidth  + ((r1.right - r1.left) - (r2.right - r2.left)), NewClientHeight + ((r1.bottom - r1.top) - (r2.bottom - r2.top)), TRUE)) return 0;
    
    /* success */
    return 1;                    
}

Nice, I'll have to rewrite it for VB, I hope I find the damed file with all those DECLAREs for API functions :lol:
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#53
Is there any library that spares the programmer the complexities of Win32 programming? Well, FreeBasic probably does that without libraries (I think), but apart from that, is there something I can use with a good C compiler? Would SDL be it? At least would it be all I need for games or graphics applications?
Reply
#54
You could use SDL for a game, its fairly easy to get the basics.

As for regular windows programs, i'm sure there are librarys that do it for you, but i've not seen any i liked the look of.

Visual Basic could be a good solution, but as far as i know only the .NET one is available free (apart from the learning editions of VB5 and VB6, which can't produce exes), and i'm not sure if it has any restrictions.

I would say dive into WinAPI, its seems horrible at first but once you get the hang of it it's not too bad, and it's quite well documented, with examples all over the net, especially if you are using C.
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#55
Allegro all the way. It's the closest experience to coding in BASIC that you can get in C for Win32, MSDOS, Linux and many more platforms.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#56
Maybe Allegro would be the way for you. I've been looking at some librarys lately.

I tried SDL but it has syncing issues. I asked at SDL and was told they don't officially support syncing. You have to use the OpenGL modes instead. For me this was not a solution as i don't want to learn OpenGL.

I also tried Allegro, which was better, but it has issues with some of the computers (or probably rather the video cards) i tried my tests on. I'm not sure yet if this can be got round. From all reports though it does work nicely on most machines, I think i just got unlucky.
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#57
You could try YAGL, from what people say it's good, and marzec is a good coder (he made it)


...or you could use fb's built in graphics, for software blitting, its basically top-notch, and it's made by one of the guys who works on Allegro, too. (lillo i love you!)
Reply
#58
Several good options here. I've also found a library that simplifies some of the OpenGL code; I think it's an alternative to GLUT:

http://glfw.sourceforge.net/

BTW, what's your opinion on JustBasic? Is it too slow or too simple for meaningful 2D applications? It looks good.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)