Jump to content

  • Log In with Google      Sign In   
  • Create Account

iGoogleThis

Member Since 31 Aug 2007
Offline Last Active Jul 19 2016 02:43 AM

Posts I've Made

In Topic: SDL Game Programming in C

04 July 2016 - 10:55 AM

 

They are either not in C or outdated

 

The "not in C" part you'll have to cope with because of your choice to use C rather than C++.  

 

The system by itself is C-based and all that knowledge can be directly used. Tutorials that use C++ stuff should be easily adjusted assuming you actually know C. Note that if you don't know how to program, picking a graphical game system like SDL is not the ideal place to learn the basics.  If you don't already know how to program in the language you should start simple, with 'guess the number', 'tic tac toe', and other simple games instead of complex graphical games.

 

 

 

That out of the way, what specifically do you want to learn about SDL that is not addressed in the links or contents of their wiki (https://wiki.libsdl.org/Tutorials) or documentation?

 

 

 

The way you use SDL does not differ from language to language. If you understand what's going on in a C++ tutorial, you can (usually trivially) write the same program in C (as far as SDL goes). Sure it'd be nice if you could find tutorials that are exactly what you need, but most of the time this won't be the case; you'll always have to change things.

 

One doesn't have pointers as a primary feature, the other does. Hell, both a programmer and a non-programmer can tell you that the syntax in even the classic "Hello World" example does not look the same. I like to use the example that saying "C/C++" in general is like saying "this tutorial is written in Spanish/Italian" while being written in just Spanish. Now imagine people just thought it was "your problem" that you only spoke Italian, really?

 

This debate has been bought up before and on multiple occasions otherwise. It's not much of a discussion since it's fairly obvious, the general consensus is that the two are - surprise - different and should be respected as such. So just because you can learn Portuguese if you know Spanish and vice-versa, doesn't mean you should have to, let alone want to.

 

See: A Raging C/C++ Debate on /r/Programming

 

Now to help out the OP, hint, go back in time. It's possible on the web, read and compile a bunch of those tutorials and go from there.


In Topic: Current state of custom and commercial game engines as of 2014

04 November 2014 - 04:18 PM

Personally I wish I could program as low as I wanted to.  I always have the urge to toss assembly in-line but too much of it leads to portability issues and when shipping a product we as developers like to avoid too much headache. In comes the commercial game engine market right?  They solved a problem fair and square and lowered the barrier of entry.  Which equals more and more independent games. Personally I program everything in C and nothing else but as mentioned here that's because I like to know how things work and it's fast, programmers like fast.

 

At my company we use custom tech only but that's because we don't rely on games as our primary area of business so we can. It is a resource strain otherwise. I've worked on teams that have used Unity but it's like driving a car with a blindfold to me.


In Topic: First Paradise - Hybrid Interactive Fiction

11 May 2014 - 05:41 PM

You can now download both a Windows and Linux build here!


In Topic: Plucking strings from an array

12 December 2013 - 01:08 PM

hey GD,  I have some code I'm trying to get working.  The goal is to take one random string from 2 different arrays and print the result.  Based on the tests I've run I'm having trouble getting a string and not just a set of numbers or unknown characters for some odd reason.  Here is a modified (for clarity) example of what I have now.

void NameGen(WINDOW *win)
{
srand(time(NULL));

	int lstn = rand() % 5;
	int fstn = rand() % 5;


char *surname[5] = { "Carter", "Nagano", "Johnson", "Boustrup", "Smith"};
char *first_name[5] = {"Jeremy", "Chris", "Aya", "Corey", "Eiden"};

wprintw(win, "%s, %s", surname[lstn], first_name[fstn]); 

}

EDIT: Fixed, the above example is actually, infact, exactly how one would go about doing this.  By seeding and setting rand() to the same value as the array you essentially leave it up to the program to spit the results back out at you.  The above sample also works with single characters and numbers.  there is plenty of room for optimization, this function is barebones.  I suggest having something offset a recalculation if you plan on calling something like this more than once so that you don't generate different names every time (unless that's what you desire).


In Topic: Continue reading after set indicators? C FILE I/O

14 July 2013 - 05:11 PM

 

Well something like this should work:

bool useDataFromNowOn = false;

while(!feof(fp))
{
    int ch = fgetc(fp);

    if(useDataFromNowOn)
    {
        ... do something with ch
    }

    if(ch == '*')
    {
        useDataFromNowOn = true;
    }
}

 

You are mighty, thanks!


PARTNERS