This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 28 Jul 2007 09:08:06 pm    Post subject:

I've recently decided to take up homebrew Nintendo DS programming. I've decided to make my first project a point-and-click adventure game (or rather, hover-and-tap :biggrin: ). I don't have much experience programming C++, but I know Java, and I've read much of this tutorial.

Anyway, here's my question. I've started planning the game engine, and I decided that there should be standard room and item classes. They would have variables for images, location, etc., and methods for displaying itself, reacting to a stylus tap, etc. Now, most objects would use generic functions, but for special objects (like a room that runs special code when it's entered), is there a way to overwrite functions in specific objects? Basically, I need a way to redefine functions in individual class instances. I realize I could create a generic class, then have specific room classes that inherit the generic class, and use polymorphism to store them all in one array, but I think there should be a simpler way to do this.

Any ideas? :confused:
Back to top
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 28 Jul 2007 09:27:50 pm    Post subject:

I haven't done much C++, but maybe you could try using templates?
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 28 Jul 2007 09:40:21 pm    Post subject:

Hmm. I don't quite get what templates do. Are they like generics in Java?

I looked on a game development forum, and I think that creating a unique class for every object might be best after all, since it seems other games do the same. I just need to learn how polymorphism works in C++ so that I can store all the objects in arrays (I figure each room can have an array of the objects it's holding, or else maybe I'll have a global array of all objects, and each room will have an array of indexes of the objects it "contains").
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 28 Jul 2007 10:18:42 pm    Post subject:

Wow, just today I starting poking around the Net for tutorials on C++ games...I was trying to figure out how to output ASCII to the DOS screen...

I'm no expert at C++, I only have a very basic knowledge of <iostream>...but making DS games? O_o

[/a spam post (delete me if you want)]
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 28 Jul 2007 10:49:45 pm    Post subject:

Yup. I have a habit of coming up with ideas for advanced projects that I often give up during planning stages, but occasionally come to fruition (ex. CalcUtil). I figure it'd be cool to make a DS game, so I'm going to give it a shot and see what happens :biggrin:.

Btw, what's up with the
Quote:
[/a spam post (delete me if you want)]
at the end of your post?
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 28 Jul 2007 10:58:17 pm    Post subject:

*glances guiltily at his abandoned xLIB Metroid*

That was because I gave absolutely no help and was somewhat narcissistic in that post.

Hm...but don't you need some way to transfer the game to your DS? Or can you compile it into an emu-compatible format?

If you could, it'd be cool to make something for GBA...
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 28 Jul 2007 11:14:07 pm    Post subject:

Well, a bunch of cool people who I don't know went ahead and found ways to run code on the DS (and originally, the GBA). Companies like SuperCard, M3, and other make cartridges that fit into the GBA slot and accept SD cards. Then you put your code on the SD card and run it. It's a bit more complicated than that, but that's the general idea.
Back to top
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 29 Jul 2007 02:26:18 am    Post subject:

magicdanw wrote:
Hmm.  I don't quite get what templates do.  Are they like generics in Java?

I looked on a game development forum, and I think that creating a unique class for every object might be best after all, since it seems other games do the same.  I just need to learn how polymorphism works in C++ so that I can store all the objects in arrays (I figure each room can have an array of the objects it's holding, or else maybe I'll have a global array of all objects, and each room will have an array of indexes of the objects it "contains").
From the article I linked to: "C++ templates provide a way to re-use source code as opposed to inheritance and composition which provide a way to re-use object code."
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 29 Jul 2007 05:38:27 am    Post subject:

magicdanw wrote:
like a room that runs special code when it's entered
What you want is scripting. You could make your own script language and write a parser for this, or use pointers to hardcoded script functions and associate them with events. So you would have a function that takes a parameter for the triggered script event and runs the associated script function. But a seperate script language with data files and a script parser would be better.

Last edited by Guest on 29 Jul 2007 05:39:00 am; edited 1 time in total
Back to top
AaroneusTheGreat


Advanced Member


Joined: 01 May 2007
Posts: 290

Posted: 29 Jul 2007 10:07:47 am    Post subject:

I'd suggest getting a book called C++ From Scratch It's well written and has very detailed descriptions of how to use the C++ functions, and it comes with a copy of Microsoft Visual C++ 6.0 (I know it's Micro$uck but it's actually a good compiler) and several things like SRMA (Shadow Realm Model Animator) a 3D model creator and animator. And a level creator.

Look it up at your local Borders or Books A Million or Barnes and Noble or something. They should have it, that's where I got mine. (I haven't picked it up and looked at it in forever, I should have before I posted about the filewriting. Razz)

Just a thought. Hope this helps.

EDIT:

I like your avitar Arcane. Smile It's nifty.


Last edited by Guest on 29 Jul 2007 10:09:26 am; edited 1 time in total
Back to top
CoBB


Active Member


Joined: 30 Jun 2003
Posts: 720

Posted: 29 Jul 2007 10:17:22 am    Post subject:

magicdanw wrote:
Anyway, here's my question.  I've started planning the game engine, and I decided that there should be standard room and item classes.  They would have variables for images, location, etc., and methods for displaying itself, reacting to a stylus tap, etc.

Yes, this seems to be a good design choice overall, although you need to consider if you’re better off creating a few generic object types. As Arcane said, it’s best to define game specific behaviour in some scripting language, and you only need to implement the primitives of this language.

For instance, in Acelgoyobis (see my sig) there are exactly three types of objects (timer, counter and hit area with optional associated graphics) and a scripting language operating on them with just a few possible commands the game engine is aware of, and all of the action on the tables is described with these few elements. You can check out the levels in the editor to see how this is realised. It made development easier and the code much more maintainable, so I really recommend this way. But again, you have to give a lot of thought as to what the primitive entities and operations are, and they shouldn’t be very specific, otherwise the language becomes bloated and hard to work with.

magicdanw wrote:
Now, most objects would use generic functions, but for special objects (like a room that runs special code when it's entered), is there a way to overwrite functions in specific objects?  Basically, I need a way to redefine functions in individual class instances.

Obviously, if there is some property that changes with every instance, it shouldn’t be expressed in the class hierarchy. The closest you can achieve in C++ is implementing all the possible behaviours as separate functions with the same signature, then store a function pointer in each room referring to the appropriate one. However, this makes sense only if every function is generic enough to be used in many places. If everything is very different, defining your scripting language is the way to go.
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 29 Jul 2007 03:58:58 pm    Post subject:

Wow! Thanks for all the great responses!

spandiv: I think I see what you mean now about templates, but I'm not sure that's what I'm looking for.

AaroneusTheGreat: I'll look into that book. It's probably best that I try to learn C++ for real before I write a game, I suppose. Sad However, I can't use the Visual C++ compiler, since I need to use a special Arm7/Arm9 version of GCC to code for the DS.

ArcaneWizard and CoBB: I guess it sounds like a scripting language is the way to go. I've never written anything like this, certainly not for a platform like the DS, so maybe I should mess around with some smaller programs (like puzzles and stuff) to get the hang of the graphics libraries for the DS. Also, are their any tutorials on creating a scripting language? :biggrin:

Thanks, everyone, for all your help!
Back to top
AaroneusTheGreat


Advanced Member


Joined: 01 May 2007
Posts: 290

Posted: 29 Jul 2007 04:14:29 pm    Post subject:

Dont you have to build a framework around a scripting language? And wouldn't that mean you had to know a lot about the base language to build the framework for the scripting language? I really don't know a lot about scripting languages, so perhaps you should just listen to Arcane and CoBB.

Last edited by Guest on 29 Jul 2007 04:14:56 pm; edited 1 time in total
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 29 Jul 2007 04:17:28 pm    Post subject:

Well, I'm guessing that building a scripting language for a game requires as much knowledge about C++ as writing the game would, so this way I just have to learn more to begin.

BTW, about the scripts, how would they integrate themselves in a project like this. With DS development, your code and graphics get compiled into one .nds binary. So would the scripts get compiled into the binary, or would they be an extra file to put on the DS?
Back to top
CoBB


Active Member


Joined: 30 Jun 2003
Posts: 720

Posted: 29 Jul 2007 04:33:52 pm    Post subject:

AaroneusTheGreat wrote:
Dont you have to build a framework around a scripting language? And wouldn't that mean you had to know a lot about the base language to build the framework for the scripting language?

It doesn’t have to be very complex, really. Of course you need to have a firm grasp of the language you’re using, but creating a simple scripting language is definitely not the hardest subtask of game development.

magicdanw wrote:
Well, I'm guessing that building a scripting language for a game requires as much knowledge about C++ as writing the game would, so this way I just have to learn more to begin.

It is actually a generally recommended exercise to implement a parser and a compiler in the language you’re learning after you got past the basics, and if the language you’re implementing is simple enough (say, something assembly-like with assignments and conditional gotos), it’s quite appropriate for one’s level at that point.

magicdanw wrote:
BTW, about the scripts, how would they integrate themselves in a project like this.  With DS development, your code and graphics get compiled into one .nds binary.  So would the scripts get compiled into the binary, or would they be an extra file to put on the DS?

This is up to you. Whichever seems the less hassle is the better solution. A nice thing about scripts is that you don’t need to rebuild your program after each modification if you keep them separate. Also, I’d recommend to have two forms of the script: a textual form for editing on the desktop and a bytecode form for efficient execution on the DS.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 30 Jul 2007 07:25:26 am    Post subject:

AaroneusTheGreat wrote:
Dont you have to build a framework around a scripting language?
You don't have to but you should use a framework with everything.
Back to top
AaroneusTheGreat


Advanced Member


Joined: 01 May 2007
Posts: 290

Posted: 30 Jul 2007 08:59:07 am    Post subject:

Hmm, what is the native language for the DS? If it's assembly, and you are pretty good, I'd go with coBB's suggestion. Using a scripting language sounds like basically creating your own macros for frequently used functions like drawing a sprite or putting text on the screen, or setting a font size. If that's what building a scripting language means then by all means go for it, I think that'd make your life easier.

Btw Arcane, where do you find all the cool avi's? Very Happy
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 30 Jul 2007 10:20:41 am    Post subject:

most people i've talked to about DS homebrew (3FG, tr1p1ea, etc.) say that C or ARM assembly are the best languages to use on the DS. I think it's partly because the DS can't handle OOP very well.

The DS's graphics capabilities are nothing more than copying data to memory and setting and resetting some flags to change display modes. Button inputs (i'm not sure about the touch screen, it could also be the same) works in a similar manner to direct input in ASM. Also, if you take a look at libnds.inc or whatever it's called now, it's mostly equates for memory addresses. Everything on the DS operates at a very low level, so a lower level language is preferable.


if you want to learn more about DS homebrew, you can probably talk to komak on cemetech, i know he was working a DS project that looked really promising. Or you can go onto irc.efnet.org#dscoders or look for tr1p1ea on efnet or UTI's server. Or you can go to irc.blitzed.org#dsdev and talk to the people who made devkitpro, which is what I think a lot of people use for DS homebrew.

There are a lot of DS emulators now, but I'm not sure how good they are. According to 3FG, crashing a DS is no where near as bad as crashing a calc, so emulators aren't necessary, though imho flash karts and DS slot solution are pricey.

Good luck though!


Last edited by Guest on 30 Jul 2007 10:21:11 am; edited 1 time in total
Back to top
compulsive_programmer


Newbie


Joined: 15 Apr 2007
Posts: 25

Posted: 31 Jul 2007 08:22:01 am    Post subject:

magicdanw wrote:
I've recently decided to take up homebrew Nintendo DS programming.  I've decided to make my first project a point-and-click adventure game (or rather, hover-and-tap  :biggrin: ).  I don't have much experience programming C++, but I know Java, and I've read much of this tutorial.

Anyway, here's my question.  I've started planning the game engine, and I decided that there should be standard room and item classes.  They would have variables for images, location, etc., and methods for displaying itself, reacting to a stylus tap, etc.  Now, most objects would use generic functions, but for special objects (like a room that runs special code when it's entered), is there a way to overwrite functions in specific objects?  Basically, I need a way to redefine functions in individual class instances.  I realize I could create a generic class, then have specific room classes that inherit the generic class, and use polymorphism to store them all in one array, but I think there should be a simpler way to do this.

Any ideas?  :confused:
[post="110580"]<{POST_SNAPBACK}>[/post]

I think templates would be your best option, at least for the task you're describing, since depending on the object or entity they are acting on, they can execute code designed for that specific object. PC game programmers and console programmers often use templates to solve engine coding problems like these. If you need an overveiw of what templates are, visite This Webpage for info, created by Mr. Stroutstrup himself.
Back to top
CoBB


Active Member


Joined: 30 Jun 2003
Posts: 720

Posted: 31 Jul 2007 10:04:00 am    Post subject:

compulsive_programmer wrote:
I think templates would be your best option, at least for the task you're describing, since depending on the object or entity they are acting on, they can execute code designed for that specific object.

Templates are parameterised by types, so unless each room is represented by a different type (ouch!), they provide no solution to this particular problem.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement