Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
npc movement on tiles
#31
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).
Reply
#32
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.
Reply
#33
Code:
PRESET (x, y)

is like

Code:
PSET (x, y), 0
B 4 EVER
Reply
#34
i know. whats the difference? aint this apopluar topic
Reply
#35
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
B 4 EVER
Reply
#36
OK, so you want to change graphics/data without having to input a key??
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.
Reply
#37
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...
ammit potato!
Reply
#38
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?
Reply
#39
Agamemnus-
are you saying have npc move with out input form user? if yes then that is what i want.
Reply
#40
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...
ammit potato!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)