Qbasicnews.com
February 23, 2020, 07:44:56 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 [3] 4
  Print  
Author Topic: npc movement on tiles  (Read 10387 times)
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #30 on: August 27, 2003, 06:44:46 PM »

What's wrong with Vic Luce's tutorials? They'll explain all of this for you.

They're located on the main qbasicnews site, under tutorial centre. (Some are in the FAQ, but I haven't finished putting them up yet, and the one you need isn't in there yet).
Logged

Diroga
Been there, done that
*****
Posts: 1087


« Reply #31 on: August 27, 2003, 07:19:16 PM »

i read all the ones here on gaming. they dont cover sprite movement and npc movement at the same time, thats my problem getting both to fluidly move with out waiting of eachother  to move.
Logged
ak00ma
Ancient Guru
****
Posts: 669



« Reply #32 on: August 28, 2003, 01:14:27 AM »

Code:

PRESET (x, y)


is like

Code:

PSET (x, y), 0
Logged

B 4 EVER
Diroga
Been there, done that
*****
Posts: 1087


« Reply #33 on: August 28, 2003, 01:38:30 AM »

i know. whats the difference? aint this apopluar topic
Logged
ak00ma
Ancient Guru
****
Posts: 669



« Reply #34 on: August 28, 2003, 01:42:35 AM »

I just felt like using "PRESET" instead of "PSET"

Here's the code so the NPC knows where to go:

Code:

TYPE npcType

xpos AS INTEGER
ypos AS INTEGER
action AS INTEGER

END TYPE

REDIM SHARED npc(100) AS npcType

DO

MoveNPC

'Player Movement

LOOP

SUB MoveNPC()

FOR n% = 0 TO 99

IF npc(n%).action = 1 THEN

dir% = INT(RND * 4)
way% = INT(RND*3)

IF dir% = 0 THEN

npc(n%).xpos = npc(n%).xpos + way%

ELSEIF dir% = 1 THEN

npc(n%).xpos = npc(n%).xpos - way%

ELSEIF dir% = 2 THEN

npc(n%).ypos = npc(n%).ypos + way%

ELSEIF dir% = 3 THEN

npc(n%).ypos = npc(n%).ypos - way%

END IF

NEXT n%

END SUB

Logged

B 4 EVER
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #35 on: August 28, 2003, 12:29:19 PM »

OK, so you want to change graphics/data without having to input a key??
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #36 on: August 28, 2003, 02:51:01 PM »

using "on timer gosub", so i have npc's moving while the "timer on" is working. Opening menus turns off the timer, so the nps and everything stops moving with boxes open.

So if you want npc's to move, even if your player isn't moving, make a timed loop or something. dunno if that's what you mean...
Logged

ammit potato!
Diroga
Been there, done that
*****
Posts: 1087


« Reply #37 on: August 28, 2003, 05:48:56 PM »

potato-
yeah thats what i want, npc move even if my guy isnt. how would i work out the loop? i have to have a loop for the INKEY$ plus the loop for the npc. do i put them in the same loop?
Logged
Diroga
Been there, done that
*****
Posts: 1087


« Reply #38 on: August 28, 2003, 05:49:50 PM »

Agamemnus-
are you saying have npc move with out input form user? if yes then that is what i want.
Logged
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #39 on: August 28, 2003, 06:16:19 PM »

Code:

ON TIMER(1) GOSUB MoveNPCs
TIMER ON

DO
GetUserMove
LOOP

MoveNPCs:
UpdateNPCs
RETURN


This will make the sprites move every 1 second, whether or not the user makes an action. GetUserMove and UpdateNPCS represents subs.

Instead of ON TIMER you can also do this:

Code:

DO
t = TIMER
GetUserMove
IF timer - t = 1 THEN UpdateNPCS
LOOP


i know some of you don't like the ON TIMER function...
Logged

ammit potato!
Diroga
Been there, done that
*****
Posts: 1087


« Reply #40 on: August 28, 2003, 06:23:40 PM »

with the on timer every second the npc moves. so that means it brakes the getusermove loop?
Logged
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #41 on: August 28, 2003, 06:27:48 PM »

Yes, but that sub should contain only computational info, like:

npcX(1) = npcX(1) - 1

moving the npc image to the left, and then you can animate that. Any keys you pressed should still be trapped, so if you're moving the character at the same time as the npc, there should be very little difference. You could always add a TIMER OFF if you want to stop NPCs altogether, and then TIMER ON when you're ready to move them again.
Logged

ammit potato!
barok
Na_th_an
*****
Posts: 1727


How about a tasty lead sandwich?


« Reply #42 on: August 28, 2003, 06:52:40 PM »

dude, why not just do what all the other qb games i have seen do: make fixed npcs?  :lol:
Logged

Jumping Jahoolipers!
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #43 on: August 28, 2003, 06:58:53 PM »

fixed npcs rock, they're signs with different pictures
Logged

ammit potato!
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #44 on: August 28, 2003, 07:21:23 PM »

ON TIMER is a bad way to do it. Do it like this.

Simple example:

Code:

t1# = TIMER
update.time# = .1

DO
IF abs(TIMER - t1#) > update.time# THEN
t1# = TIMER

'update logic and graphics..
update.logic
update.screen
END IF

SELECT CASE INKEY$
END SELECT
LOOP


You need the ABS if TIMER is about to roll-over... which only happens one second every day. Smiley
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Pages: 1 2 [3] 4
  Print  
 
Jump to:  

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