RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
QB-related question for all with such knowledge...
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
Astantax
Lowly Slime


Joined: 01 Jan 2008
Posts: 1

PostPosted: Tue Jan 01, 2008 10:17 pm    Post subject: QB-related question for all with such knowledge... [quote]

Hey, all

I've been trying to make the same QB rpg for about a decade now. In 2002 I suffered a major computer malfunction that set me back months and months. The solutions to many problems I'd solved were lost. Now I'm finally set to pick up the pieces and finish.

Background:
I'm using GSlib. I'm not sure if that's the best choice or if any of you have even ever heard of it. My main problem is this:

I have NPCs that move around randomly on their own. The engine I made is pix * pix scrolling (courteousy of GSlibs' ability to place sprites outside of the screen boundaries, so yeah it's kind of cheating a little). The problem is that they move around tile x tile. I'm having a little trouble figuring out how to animate them while keeping the main game loop (and subsequently player movement) delay-free. I also have begun to implement the most rudimentary animated tiles, using the ON TIMER function. This is not going to work because ON TIMER can only use integers, so the shortest interval I can work with is only 1 second.

I tried defining a new variable as equal to .25 + TIMER (which is seconds elapsed until midnight in QB), and when TIMER = this new variable to gosub to the animation routine that scrolls the NPCs (if they're moving) and animates certain tiles, but so far this doesn't work.

Is there a way to toss animated tiles and about 15 NPCs scrolling at once in such a QB engine without switching libraries?

- Brian
Back to top  
Nodtveidt
Demon Hunter


Joined: 11 Nov 2002
Posts: 786
Location: Camuy, PR

PostPosted: Wed Jan 02, 2008 6:58 am    Post subject: [quote]

GSlib, short for Gouldsoft Library, developed by Jason Gould (aka "The Brain"). Both old QB groups I coded for used it (Lost socK and Darkness Ethereal). It's very good. Anyways, if I were you, I'd ditch the TIMER stuff and stick to frame-based gameplay. Lock your game in to a framerate and stick to it (60fps is the standard for SCREEN 13). It's easy to do if you wait for the vertical refresh.

A good way to do animated tiles is to wait a certain number of frames and then update their graphics. In a frame-based system, this is called "ticking", as the time for each frame is called a "tick". So, if you're using 60fps, you've got 60 ticks per second. Say you want to update your graphics 5 times a second. Divide the number of ticks per second (60) by the number of updates you want to do (5) and you get 12...what you'd do is have a variable (a "tick counter") that keeps track of the ticks (increment it every frame), and when it reaches your desired time (12, in this case), you update your graphics and then set the variable back to zero ("reset the tick counter").

To handle the movement of your NPCs, you would do an "update" once per trip through your game loop. The NPCs could also use ticks to determine how often they move, how fast they move, etc. For example: you want to move an NPC every 3 seconds. This would be 180 ticks. Also, let's say you want them to walk slowly from tile to tile. Well, maybe they could be updated every 10 ticks (giving them a move rate of 6 pixels per second if you're moving them one pixel at a time). In order to not get confused as to what your NPC is doing, create for them a second variable that contains data about their current action, or what is called a "state". That way, you can look at this "state variable" and use it to determine what to do with your NPC...let's say if the NPC's state is 0, then it's just standing around, waiting for its tick counter to reach 180 so it can move again. Then, when its tick counter reaches 180, reset the tick counter to 0 again, and set its state variable to 1 to tell your game engine that your NPC is on the move. Once your NPC finishes its movement, set its state variable back to 0 so it can wait for another move. So on and so forth.

Sorry if this is a little confusing...it's almost 3 in the morning so I might be rambling incoherently again. :D
_________________
If you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows. - wallace
Back to top  
BadMrBox
Bringer of Apocalypse


Joined: 26 Jun 2002
Posts: 1022
Location: Dark Forest's of Sweden

PostPosted: Wed Jan 02, 2008 3:13 pm    Post subject: [quote]

I used to use GSLib too, before I switched to RELLib. I would say that Nod's text makes good sense even as it is written at 3 in the morning :)
_________________
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum