Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
Calculator Community
»
Other Calculators
»
Programming RPG's...
« previous
next »
Print
Pages: [
1
]
2
Go Down
Author
Topic: Programming RPG's... (Read 5489 times)
0 Members and 1 Guest are viewing this topic.
Alex
Guest
Programming RPG's...
«
on:
May 19, 2006, 05:39:00 am »
Someday (far far away) I might start working on an RPG game for the 68k's. I know how a tilemap works, but specific events triggered by certain locations have me stumped. Let's say you walk over a tile that has a door drawn on it - how do you go to another room by passing through the door? I have the idea of having a tilemap of events over the graphics tilemap, and have each number on the event tilemap assigned to a sub-program/function that would handle that event. Not very flexible, but should work.
What methods do you use?
- Alex
Logged
tifreak
LV11
Super Veteran (Next: 3000)
Posts: 2708
Rating: +82/-3
My Kung Fu IS strong...
Programming RPG's...
«
Reply #1 on:
May 19, 2006, 06:18:00 am »
Well, I program Z80 basic, though the principle should work just the same for 68k basic (and the asm and C languages as well).
Inside the walking engine, I have the calculator do a check to see if the tile that the character is currently sitting on is a tile that would take it to a different area, or for that matter, have it do something else entirely. It just depends on the situation.
Anyways, it checks to see if it equals that particular tile, either by numerical value, or by a character representing it, depending on hit detection methods. If the boolean is true, then it calls another program, to do the redirect from there, allowing the engine to stay fairly small, and not become bloated with that other code.
Do you understand, or would you like me to provide sample code (it would be in z80 basic)??
Logged
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%
Alex
Guest
Programming RPG's...
«
Reply #2 on:
May 19, 2006, 08:13:00 am »
Let's see if I get this right:
Tilemap:
000000000
008000000
000000900
000000000
000000000
Pseudo-code:
if(tile_player_is_on ==
subprogram()
else if(tile_player_is_on == 9) subprogram2()
subprogram and subprogram2 contain the redirect or specific data that I want to happen when the player is on that tile.
- Alex
Logged
tifreak
LV11
Super Veteran (Next: 3000)
Posts: 2708
Rating: +82/-3
My Kung Fu IS strong...
Programming RPG's...
«
Reply #3 on:
May 19, 2006, 08:43:00 am »
Sort of...
to make it easier, and the engine more compact, I have it do this:
If (Char Position) != 0: prgmEvent
This works wonderfully, as long as inside the movement, you restirct where the character can go.
Inside prgmEvent:
If (Char Position) = 8:
Deal with Event
If (Char Position) = 9:
Deal with Event
etc...
prgmEvent also redirects to another program, if neccessary. I have found this increases the speed of things on the z80, though I have only made a couple progs on the 68k basic, so I don't know a whole lot about it...
Logged
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%
Liazon
Guest
Programming RPG's...
«
Reply #4 on:
May 19, 2006, 09:25:00 am »
It looks like a switch/case structure would be a tempting idea.
hey, btw Alex, can you use run a function if you know the pointer to the function, or can that only be done in 68k ASM?
Logged
Alex
Guest
Programming RPG's...
«
Reply #5 on:
May 19, 2006, 09:37:00 am »
Pointers to functions seems like the way to go. I sure that it can be done in C, but I'll have to look it up.
Let's say tiles with number greater than 0 are event triggers on the event tile map:
void function(void) {
//do something
}
void function2(void) {
//do something else
}
void* functions[2] = { function, function2 };
...
if(tile > 0) functions[tile];
Of course, this code is wrong, but that's the structure I'm going for.
Keep the ideas coming, and thank you everyone!
- Alex
Logged
Alex
Guest
Programming RPG's...
«
Reply #6 on:
May 19, 2006, 10:36:00 am »
I just found something:
http://www.newty.de/fpt/fpt.html
In C it would be:
void function(void);
void function2(void);
void (*functions[2])(void) = { NULL };
functions[0] = &function;
functions[1] = &function2;
...
if(tile > 0) (*functions[tile])();
It should work in TIGCC, perhaps with a little tweaking of the pointer casts.
- Alex
Logged
saubue
Guest
Programming RPG's...
«
Reply #7 on:
May 19, 2006, 11:58:00 am »
Good idea! It seems like I can also implement this into Shadow Falls for some optimization
Logged
Fryedsoft
LV3
Member (Next: 100)
Posts: 90
Rating: +2/-0
Programming RPG's...
«
Reply #8 on:
May 19, 2006, 12:04:00 pm »
# (Indirection) and Expr( are your best friends on the 89, but in this case Expr( is.
basicially...
c1-->
CODE
ec1
If (tilenumber) != 0
expr("run"&string(tilenumber)&"()")
c2
ec2
if tilenumber = 5, the expr command will execute run5. 6 will execute run6, ETC. if you put a variable between the "()" (say Tilenumber for example) it will send that variable to the program, so if tilenumber was 6, it would be execute run6(6).
Logged
BlueCrimson - The Future of Ti-Basic, Today
Liazon
Guest
Programming RPG's...
«
Reply #9 on:
May 19, 2006, 02:10:00 pm »
QuoteBegin-Alex+May 19 2006, 04:36 PM-->
QUOTE
(Alex @ May 19 2006, 04:36 PM)
I just found something:
http://www.newty.de/fpt/fpt.html
In C it would be:
void function(void);
void function2(void);
void (*functions[2])(void) = { NULL };
functions[0] = &function;
functions[1] = &function2;
...
if(tile > 0) (*functions[tile])();
It should work in TIGCC, perhaps with a little tweaking of the pointer casts.
- Alex
Awesome!! no idea how this code works, but I'll figure it out. I made the suggestion only because in z80 ASM, you could probably store the location of a function/label into a variable, and then jump to that function.
So, the ASM would look like a switch case block where each option stored a different function location/address to the address variable that the main funtion will jump to.
Probably could be simplified more though in ASM. I guess it's this freedom that I enjoy about ASM. It's the huge amount of code in ASM that makes me prefer the niceness of C.
Logged
Alex
Guest
Programming RPG's...
«
Reply #10 on:
May 19, 2006, 02:37:00 pm »
Yea, there's something about nicely structured, tabbed C code that screams "pure logic!".
- Alex
Logged
Dragon__lance
Guest
Programming RPG's...
«
Reply #11 on:
May 19, 2006, 03:38:00 pm »
hey guys, correct me if i'm wrong:
In z80 ASM, wouldn't you use vector tables to do the jumping for doors and such in a tilemap routine?
Logged
Liazon
Guest
Programming RPG's...
«
Reply #12 on:
May 20, 2006, 05:32:00 am »
Maybe that's what it's called. I haven't looked at z80 ASM in ages
.
Either way, it's the idea that labels are address/pointers to functions, which in ASM can be used as a jump location. I just wasn't sure if it could still be done in C. otherwise a most likely bloated C if else structure would probably be needed.
Logged
saubue
Guest
Programming RPG's...
«
Reply #13 on:
May 20, 2006, 09:32:00 am »
QuoteBegin-Alex+May 20 2006, 03:37 AM-->
QUOTE
(Alex @ May 20 2006, 03:37 AM)
Yea, there's something about nicely structured, tabbed C code that screams "pure logic!".
- Alex
Right, but I like C++ more, because classes make it even more logical to me. That might by a reason why I like using typedef structs in my C projects...
Logged
Alex
Guest
Programming RPG's...
«
Reply #14 on:
May 20, 2006, 10:20:00 am »
Yea, structures are great. I just recently started using them for File I/O, but I'm sure that gradually I'll use them more and more.
- Alex
Logged
Print
Pages: [
1
]
2
Go Up
« previous
next »
Omnimaga
»
Forum
»
Calculator Community
»
Other Calculators
»
Programming RPG's...