The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
December 07, 2024, 09:12:03 am
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Starbase Café (Moderator: Death 999)
| | |-+  Programming
« previous next »
Pages: 1 [2] 3 4 Print
Author Topic: Programming  (Read 7705 times)
Valos Cor
*Many bubbles*
***
Offline Offline

Gender: Male
Posts: 154



View Profile
Re: Programming
« Reply #15 on: July 20, 2010, 08:46:44 pm »

I guess this its fine if I post a simple y/n question "game" program here.  It has SOMETHING to do with SC but its just one question so far but I was working hard on this because there was a bug - for some reason, if I have an if or else statement and under it I put more than one cout>> it won't work but I fixed it and I am so happy Smiley  I made it in C++ with Dev-C++.

Here it is:
(click to show/hide)
If I'm not supposed to post the executable file here...well, that was just the locations of the rainbow worlds :p

Right now, I'm trying to figure out what to do next.  Its supposed to fork in different paths whether you say y or n.  If you put Googlgotgoozabobble or some random letters, it'll give you a reply too.
Logged

I'm the kind of person that uses Linux and seems to be a very literate adult but has no idea how to do anything code-wise beyond basic stuff.(such as su -<password> yum install uqm) Except I didn't install UQM that way...I used Add/Remove Software...
Lukipela
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3620


The Ancient One


View Profile
Re: Programming
« Reply #16 on: July 20, 2010, 09:44:40 pm »

I guess this its fine if I post a simple y/n question "game" program here.  It has SOMETHING to do with SC but its just one question so far but I was working hard on this because there was a bug - for some reason, if I have an if or else statement and under it I put more than one cout>> it won't work but I fixed it and I am so happy Smiley  I made it in C++ with Dev-C++.

Dude this is the Off Topic section. You're question doesn't have to relate to Star Control in any way. Feel free to ask any unrelated stuff about coding or penguins or anything really.
Logged

What's up doc?
Valos Cor
*Many bubbles*
***
Offline Offline

Gender: Male
Posts: 154



View Profile
Re: Programming
« Reply #17 on: July 20, 2010, 10:43:02 pm »

Penguins!  In that case... may I present:

...uhh... there's nothing there. *looks up how to post pictures* tada!
Am I that stupid...*looks it up again*  I think it will work.
whatever, it doesn't work (yet)
« Last Edit: July 20, 2010, 10:47:11 pm by Valos Cor » Logged

I'm the kind of person that uses Linux and seems to be a very literate adult but has no idea how to do anything code-wise beyond basic stuff.(such as su -<password> yum install uqm) Except I didn't install UQM that way...I used Add/Remove Software...
Novus
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1938


Fot or not?


View Profile
Re: Programming
« Reply #18 on: July 21, 2010, 02:54:31 am »

Dude this is the Off Topic section. You're question doesn't have to relate to Star Control in any way. Feel free to ask any unrelated stuff about coding or penguins or anything really.
That said, it would be nice if the programming stuff were in the 'Programming' thread and the penguins in a 'Penguin' thread or suchlike, just in case someone, for example, is interested in programming but scared to death of penguins.

It has SOMETHING to do with SC but its just one question so far but I was working hard on this because there was a bug - for some reason, if I have an if or else statement and under it I put more than one cout>> it won't work but I fixed it and I am so happy Smiley  I made it in C++ with Dev-C++.
As for your program, one of the reasons I prefer Java as a teaching language is that I can easily run students' code with zero or limited access to file systems, networks and so on, rather than trust them not to do something undesirable either intentionally or unintentionally. Another is that porting Java code from e.g. Windows to Linux is no work at all if it's properly written. Furthermore, class files are often small enough that I can easily disassemble them to figure out what they do even if source code is not provided. Since examining your program is impractical in all three ways mentioned above, I can't say much about it. Source code would help.

"It won't work" is a bit vague. That said, I suspect you forgot the curly brackets.
Logged

RTFM = Read the fine manual.
RTTFAQ = Read the Ur-Quan Masters Technical FAQ.
Valos Cor
*Many bubbles*
***
Offline Offline

Gender: Male
Posts: 154



View Profile
Re: Programming
« Reply #19 on: July 21, 2010, 05:05:16 am »

It has SOMETHING to do with SC but its just one question so far but I was working hard on this because there was a bug - for some reason, if I have an if or else statement and under it I put more than one cout>> it won't work but I fixed it and I am so happy Smiley  I made it in C++ with Dev-C++.
As for your program, one of the reasons I prefer Java as a teaching language is that I can easily run students' code with zero or limited access to file systems, networks and so on, rather than trust them not to do something undesirable either intentionally or unintentionally. Another is that porting Java code from e.g. Windows to Linux is no work at all if it's properly written. Furthermore, class files are often small enough that I can easily disassemble them to figure out what they do even if source code is not provided. Since examining your program is impractical in all three ways mentioned above, I can't say much about it. Source code would help.

"It won't work" is a bit vague. That said, I suspect you forgot the curly brackets.
Sorry for not including the source file.  The problem seems to be that if I put more than one cout>> under either if or else, it will not work and expect me to have a "primary-expression" before else and a semicolon before else as well even though I do have one.   I updated the file so it will have the working executable with its working source code and the notworking executable's source code.
 not  working source :http://www.4shared.com/account/file/oGzIv3FW/notworking.html
working exe: http://www.4shared.com/account/file/cNhn2IQO/working.html
working source: http://www.4shared.com/account/file/h3tp6fRz/working.html
Logged

I'm the kind of person that uses Linux and seems to be a very literate adult but has no idea how to do anything code-wise beyond basic stuff.(such as su -<password> yum install uqm) Except I didn't install UQM that way...I used Add/Remove Software...
Resh Aleph
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 319


Rottem Tomatoes


View Profile
Re: Programming
« Reply #20 on: July 21, 2010, 10:23:18 am »


Note that C-like programming languages ignore multiple consecutive whitespace (including newlines, spaces and tabs), so

Code:
if (condition)
    statement1;
    statement2;
    statement3;

is interpreted just like this:

Code:
if (condition)
statement1;
statement2;
statement3;

or this:

Code:
if (condition)
    statement1;

statement2;
statement3;

and so on. The compiler interprets it like the last formatting suggests: "If condition holds, perform statement1. Then, regardless, perform statement2 and statement3."

What you need here is a block for grouping the three statements together:

Code:
if (condition)
{
    statement1;
    statement2;
    statement3;
}

The same goes for else if/else.

(To avoid confusion and bugs, some recommend to always use a block after if/else if/else, even if it's just a single statement in the block.)
Logged

Marines on Maulers and limpets on Earthlings  /  Bright Podship plasma and warm Kohr-Ah death rings  /
Shofixti Scouts doing gravity whips  /  These are a few of my favorite ships!
       © meep-eep
superbutcherx
*Many bubbles*
***
Offline Offline

Posts: 116



View Profile
Re: Programming
« Reply #21 on: July 21, 2010, 12:45:44 pm »

I've found
www.cplusplus.com/doc/tutorial/
useful at learning new things and rehearsing the old.

Even though it's for C++, the first parts of the tutorial (Basics of C++, Introduction, Control Structures, Compound Data Types) hold true for C since these parts are essentially the same for both languages.

The best way to learn how UQM works is to read and re-read the source files like crazy Smiley
It also helps a lot, if you have finished the game hundreds of times and played it a gazillion times. It works wonders on understanding what the functions in the source code really do.

Also, always, if you modify something in the code, add a comment with your own unique identifier at the end of the line like // ZXZ. It will save you a lot of time hunting down what you've done, especially if you leave the code alone for a couple of weeks and return to it after that. When the mod keeps growing it's not a bad idea to make a list of files that you've tinkered with and add a short summary of mods you've done to that file.
Logged
Megagun
Enlightened
*****
Offline Offline

Gender: Male
Posts: 580


Moo


View Profile
Re: Programming
« Reply #22 on: July 24, 2010, 09:41:10 pm »

I'm interested in learning how to start modding the UQM code - starting with simple stuff like editing the dialogue etc - and learning the C programming language.  Those of you who know how to mod or know C...how did you learn?  How did you start off?  I'd appreciate knowing how you did it so I'd know how I should do it.
My advice: drop the idea and learn to code in an easier language first. I'd recommend Java with either NetBeans or Eclipse as the IDE. Try writing some easy console apps, then write a simple game using Java + JOGL (NetBeans has a nice JOGL plugin, including a few good templates to get you started easily). Once done, rewrite parts of the game to use the fewest amount of classes possible, store data in byte arrays, and write your own implementations of a few functionalities you're using from the Java standard libraries.

Once done with that, you should have enough knowledge to start the transition to C, which would allow you to mod UQM somewhat.

Very slightly related, but still worth the read nonetheless: http://cube.wikispaces.com/How+not+to+start+a+mod
Logged
chenjesuwizard
*Many bubbles*
***
Offline Offline

Posts: 158


I support Project6014


View Profile
Re: Programming
« Reply #23 on: August 12, 2010, 02:23:50 pm »

I have a problem.
I used Winzip to extract the source code, then Dev C++ to edit the various files.
Then, what do I do? I can't compile the folder and when I compress the folder and then load it onto Dev C++ it comes up with weird coding, which it won't compile.
How do I compile it?
Logged

Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.
TiLT
*Smell* controller
****
Offline Offline

Gender: Male
Posts: 260


To boldly go where no Spathi has dared go before


View Profile WWW
Re: Programming
« Reply #24 on: August 13, 2010, 03:16:36 pm »

I'm interested in learning how to start modding the UQM code - starting with simple stuff like editing the dialogue etc - and learning the C programming language.  Those of you who know how to mod or know C...how did you learn?  How did you start off?  I'd appreciate knowing how you did it so I'd know how I should do it.
My advice: drop the idea and learn to code in an easier language first. I'd recommend Java with either NetBeans or Eclipse as the IDE. Try writing some easy console apps, then write a simple game using Java + JOGL (NetBeans has a nice JOGL plugin, including a few good templates to get you started easily). Once done, rewrite parts of the game to use the fewest amount of classes possible, store data in byte arrays, and write your own implementations of a few functionalities you're using from the Java standard libraries.

Once done with that, you should have enough knowledge to start the transition to C, which would allow you to mod UQM somewhat.

Very slightly related, but still worth the read nonetheless: http://cube.wikispaces.com/How+not+to+start+a+mod

I'll second this, but for different reasons. Try learning a strict object oriented language first, such as C# or Java, even if you don't intend to use them much later (though stuff like C# is probably going to inspire you if you're a Windows user). Starting with C or C++ teaches you bad habits since the two languages allow you to do just about anything you like, including stuff that isn't smart to do at all. It's easier to transition down from a high-level language than to move up from a low-level language (the first time). Trust me. I've been there. It nearly messed up my ability to get through computer science classes.
Logged
ziper1221
*Many bubbles*
***
Offline Offline

Posts: 124



View Profile
Re: Programming
« Reply #25 on: August 13, 2010, 05:12:30 pm »

On, the same note, how useful is python and Java? both of them are classes offered at my school next year.
Logged

Death 999
Global Moderator
Enlightened
*****
Offline Offline

Gender: Male
Posts: 3874


We did. You did. Yes we can. No.


View Profile
Re: Programming
« Reply #26 on: August 13, 2010, 07:43:27 pm »

Java is widely used. Knowing how to use it will be useful.

Python is a very different beast. One serious mode is just to enter commands one line at a time! It too is widely used. I can't say which is better, really. If you really want to be a serious programmer, Java might be better. If you just want to get the idea of programming, python might be better? I'm not familiar enough with python to be sure.
Logged
onpon4
Enlightened
*****
Offline Offline

Gender: Male
Posts: 709


Sharing is good.


View Profile WWW
Re: Programming
« Reply #27 on: August 14, 2010, 02:05:26 am »

Java is widely used. Knowing how to use it will be useful.

Python is a very different beast. One serious mode is just to enter commands one line at a time! It too is widely used. I can't say which is better, really. If you really want to be a serious programmer, Java might be better. If you just want to get the idea of programming, python might be better? I'm not familiar enough with python to be sure.

Python is an excellent language, IMHO. Its biggest advantages are ease-of-use, cleanliness of code (due to its unusual use of whitespace for code blocks), and that it's dynamically typed. There are also a large amount of 3rd party libraries, making it useful for a huge number of tasks, including graphical programs (i.e. games) and GUIs. Finally, it is an interpreted language, meaning you don't have to compile it; you just run it.

Of course, there is one disadvantage: Python scripts can only be run if you have Python installed. However, besides the fact that most Linux distributions come with some form of Python already, there are 3rd party modules which can "freeze", i.e. compile, scripts along with necessary Python and 3rd party components (such as py2exe, py2app, and cxFreeze), allowing people who don't have Python installed to run your program.

Not knowing much about Java, I can't say which class you should pick, if you have to choose one. I would take both if possible.
Logged

Gekko
*Many bubbles*
***
Offline Offline

Gender: Male
Posts: 199


Arena regular


View Profile
Re: Programming
« Reply #28 on: August 14, 2010, 03:27:59 am »

Java programming probably gets you a job. At least here you end up doing GUIs with Netbeans if you know Java. I'm not sure where Python is used in the market, but I like Python more than Java. If you know C/C++, then a huge load of various doors to even extraordinary places open.

If you are considering employment, then it's also important to learn the development on other platforms. It's highly different to make a program on Windows/Linux/OS X
Logged

Visit #uqm-arena and play a game of Net Melee!
Try the Net Melee Improvement mod
Novus
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1938


Fot or not?


View Profile
Re: Programming
« Reply #29 on: August 14, 2010, 12:52:42 pm »

First of all, I would like to point out that Java and Python are quite similar languages in many ways and share the same ALGOL/C origins; if you learn one, picking up the other won't be hard. Both require a separate runtime environment that is available as free software and often included in Linux distributions but not in, for example, Windows. Although they are both general-purpose platform-independent languages, they target different uses: Python tends to see lots of use as a quick and convenient language to control or extend other programs (e.g. web servers, 3D animation software, games), while Java tends to show up in user-facing software more (applets, desktop applications).

My impression of how these two languages are developing is that Java has a stronger emphasis on building and maintaining systems (corporate priorities), while Python focuses on being clean and straightforward to write in (hacker priorities). If you're writing something to get a job done for yourself, Python may be less work, but I wouldn't want to base a major corporate infrastructure on it quite yet.

As far as learning goes, Python is probably the better bet as a first programming language (mostly because of its cleaner syntax and lack of clutter in small programs), although Java isn't much worse.
Logged

RTFM = Read the fine manual.
RTTFAQ = Read the Ur-Quan Masters Technical FAQ.
Pages: 1 [2] 3 4 Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!