Posts: 3,343
Threads: 83
Joined: Mar 2003
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).
Posts: 1,057
Threads: 156
Joined: Aug 2003
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.
Posts: 594
Threads: 11
Joined: Oct 2002
Posts: 1,057
Threads: 156
Joined: Aug 2003
i know. whats the difference? aint this apopluar topic
Posts: 594
Threads: 11
Joined: Oct 2002
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
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Posts: 394
Threads: 16
Joined: Jun 2003
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!
Posts: 1,057
Threads: 156
Joined: Aug 2003
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?
Posts: 1,057
Threads: 156
Joined: Aug 2003
Agamemnus-
are you saying have npc move with out input form user? if yes then that is what i want.
Posts: 394
Threads: 16
Joined: Jun 2003
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!