Randomized Graphics

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
User avatar
Shaggy02
Newbie
Posts:2
Joined:Fri May 10, 2002 7:39 am
Location:West Virginia
Contact:
Randomized Graphics

Post by Shaggy02 » Fri May 10, 2002 7:54 am

    My friend and I are working on our first game ever.  We have a few questions and it would be great if someone could help us.  
    We are doing an adventure type game and we have "bad guys" that we want to randomly move around the screen.  Not from like one side to the other side and such, but like move randomly one tile at a time.
    If you could e-mail me or even send me some program code that has this in it so we can learn how to do it...that would be greatly appreciated.  Thanks!

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: Randomized Graphics

Post by frankiebaby » Tue May 14, 2002 2:14 am

Weeelllll...... I suppose you could get a random number to stand for the direction to move, say 1 thru 4, for up, dwn, left, and right. You could then generate a random number for how many tiles(??) to move. then when your loops have moved it that many tiles, or when its about to go off screen......get new numbers

User avatar
Zander
Newbie
Posts:2
Joined:Thu May 23, 2002 10:41 am
Location:South CackalackIe
Contact:

Re: Randomized Graphics

Post by Zander » Thu May 23, 2002 11:05 am

I have an idea to build upon his. Now I am new to this so if it doesn't work then just tell me and I will keep my mouth shut but, if you take his four #'s and randomly pick one it would move about randomly. But it might move off screen and that would suck. Do you think you could set up some sort of " IF blah blah THEN blah blah"
to cover up for it? Like make it so that  "IF" it reaches that tile "THEN" make it randomly choose a direction other than the one that would make it go off screen. I am not completely sure as to how you would go about doing this but it should be possible. If any of the more experienced programmers see this would you please tell me weather it will work or not?
   I hope I helped,
;D Later!
"Skate 2 Live,
Skate 4 Life."

Zander Badlin

User avatar
Shaggy02
Newbie
Posts:2
Joined:Fri May 10, 2002 7:39 am
Location:West Virginia
Contact:

Re: Randomized Graphics

Post by Shaggy02 » Fri May 24, 2002 2:40 am

We have figured out the random graphics ourself, but thanks to all.  Yes there is a way to keep the graphic from going off screen.  In screen 7 dimensions are 200 x 300 I believe. So to do it it would be:

if (y = 290 or y > 290)  then
   y =290
end if

and you would do that for each direction and it should work out for you.  Thanks for the help and I hope by helping me, I have helped you.

madmartin55
Newbie
Posts:8
Joined:Tue Jun 18, 2002 12:25 am
Contact:

Re: Randomized Graphics

Post by madmartin55 » Tue Jul 30, 2002 12:30 pm

It would also be a good idea to remove the choice of the ">=290" in calculating the next move to keep the machine from iterating a choice that gets rejected on the next check, i.e. don't let your random generator select anything higher (lower). Sorry this reply is so late, you might have already thought of this.
stuck in a time warp

"Let's do the time warp again!"

Guest

Re: Randomized Graphics

Post by Guest » Mon Sep 09, 2002 9:41 am

Why is it bad for the image to move off the screen? I guess you could check to see if it is off the screen, and if it is, not print it to speed up the programe slightly, and even if you don't check to see if it is off, it won't cause any errors if you print it :)

Guest

Re: Randomized Graphics

Post by Guest » Mon Oct 28, 2002 3:04 am

I have built several games like this and you realy don't want to use the four number method.  you need 8 numbers and an other veriable to make it so that it doesn't jump around (move up, then down in less then a pikosecond (piko is .000 less then nano)) and example is writen below.

do
   thingy = thingy + 1
   if thingy > 10 then thingy =1      ' moves 10 tiles each time in the loop
   if thingy = 1 then move = int(rnd*7)+1
   if move = 1 and y > 0 then y = y - speed
   if move = 2 and y > 0 and x > 200 then y = speed/2: x = x + speed/2
&nbsp; &nbsp;if move = 3 and x < 200 then x = x + speed
&nbsp; &nbsp;if move = 4 then
'
'
'
'I think you get the point

thingy is the veriable for the amount of tiles the sprite has moved

10 is the amount of tiles it will move in the decided direction

it is assumed that 200 is the max x and y value (window screed (1,1)-(200,200))

its + mouse pad +, but so is screen 7 or what ever screen you are using.... screen 12 and screen 13 are what you should use for this kind of game, 7 or 13 for RPG.

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

Post Reply