Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
won't run
#1
the code compiles fine, but i get an error during runtime. The code looks good. Can anyone tell me what's wrong with this?

screen 13

type particles field=1
oldx as single
oldy as single
x as single
y as single
col as integer
life as integer
end type

dim part(100) as particles

randomize timer

do

for i = 0 to 100
if part(i).life < 0 then
part(i).life = int(100) + 100
part(i).x = int(rnd * 320)
part(i).y = int(rnd * 200)
part(i).col = 15
end if
next



for i = 0 to 100

part(i).oldx = part(i).x
part(i).oldy = part(i).y
if part(i).x < 160 then part(i).x = part(i).x + 1
if part(i).x > 160 then part(i).x = part(i).x - 1
if part(i).y < 100 then part(i).y = part(i).y + 1
if part(i).y > 100 then part(i).y = part(i).y - 1
part(i).life = part(i).life - 1

pset (part(i).oldx, part(i).oldy), 0
pset (part(i).x, part(i).y), part(i).col
next

wait &h3da,8
loop until (inkey$)



I get the classic "memory could not be read" error with this. Help is appreciated!
Jumping Jahoolipers!
Reply
#2
replace
loop until (inkey$)

with

loop until inkey$ <> ""
Oh dear,' says God, 'I hadn't thought of that,' and promptly vanished in a puff of logic."
My waste of space
Reply
#3
... Someone find me a brick to hit myself with. If i couldn't find such a simple bug, then I don't believe I deserve to program. I intend to smash in my fingers.

Btw, how come it'll compile when the loop is like this? loop (inkey$) inkey$ returns a string value, does it not?
Jumping Jahoolipers!
Reply
#4
Quote:... Someone find me a brick to hit myself with. If i couldn't find such a simple bug, then I don't believe I deserve to program. I intend to smash in my fingers.

Btw, how come it'll compile when the loop is like this? loop (inkey$) inkey$ returns a string value, does it not?

sometimes the answer is so obvious we dont see it.

Hell i almost posted a "whats wrong with this" question until i relooked over my code and it was something SO DAMN SIMPLE I convinced my self that i "couldnt mess that up its so simple"

Dont beat yourself up about it.. unless you record it and send me a copy.. i love slapstick humor .... even if half the time its only funny to me Big Grin
Oh dear,' says God, 'I hadn't thought of that,' and promptly vanished in a puff of logic."
My waste of space
Reply
#5
Code:
Loop until(Inkey$)
is a valid FB code. Loop only checks or the truth value regardless of what data type inkey$ would return.

In C, that's also a valid code so it should also be a valid FB code.

Code:
do
{
}
while(!kbhit)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#6
Actually, that was another error silently ignored, fixed..
Reply
#7
v1c rules
Reply
#8
Quote:v1c rules

yep. Big Grin

anyways, here's the complete code, for anyone who wants. I made a fountain with the particles... er... 3 fountains. (1 couldn't quite cover the screen, so i made 3.) kinda reminds me of aleksander's PFX. Wink

Code:
screen 18,,,1

type particles field=1
   oldx as single
   oldy as single
   x as single
   y as single
   col as integer
   life as integer
   directionx as string * 1
   directiony as string * 1
   incredimentx as single
   incredimenty as single
   times as integer
   end type

dim mousex as integer
dim mousey as integer
dim part(1500) as particles

setmouse ,,0
randomize timer

do
  
   for i = 0 to 1500
      if part(i).life < 0 or part(i).y > 490 then
         rndplacement = int(rnd * 3)
         select case rndplacement
         case is = 0
            part(i).x = 320
         case is = 1
            part(i).x = 100
         case is = 2
            part(i).x = 540
            end select
         part(i).life = int(rnd * 100) + 400
         'part(i).x = 320
         part(i).y = 480
         part(i).col = 9
         part(i).directionx = " "
         part(i).directiony = "u"
         part(i).incredimentx = rnd * 3 + -2
         part(i).incredimenty = -7 - (rnd * 3)
         part(i).times = 5
      end if
         pset (part(i).oldx, part(i).oldy), 0
   next
  
      
      cls
      for i = 0 to 1500
        
         part(i).oldx = part(i).x
         part(i).oldy = part(i).y
        
         'if part(i).x < 320 then part(i).directionx = "r"
         'if part(i).x > 320 then part(i).directionx = "l"
         'if part(i).y < 480 then part(i).directiony = "d"
         'if part(i).y > 480 then part(i).directiony = "u"
        
         part(i).life = part(i).life - 1
        
         'if part(i).directionx = "l" then part(i).incredimentx = part(i).incredimentx - 1' + rnd * .1'(.3 +(rnd * .1))
         'if part(i).directionx = "r" then part(i).incredimentx = part(i).incredimentx + 1' + rnd * .1'(.3 +(rnd * .1))
         if part(i).directiony = "u" then part(i).incredimenty = part(i).incredimenty + .1' + rnd * .1'(.3 +(rnd * .1))
         'if part(i).directiony = "d" then part(i).incredimenty = part(i).incredimenty - 1' + rnd * .1
        
         'if part(i).incredimentx < -part(i).times then part(i).incredimentx = -part(i).times - 1: part(i).times = part(i).times - 1
         'if part(i).incredimentx > part(i).times then part(i).incredimentx = part (i).times - 1: part(i).times = part(i).times - 1
         'if part(i).incredimenty > part(i).times then part(i).incredimenty = part(i).times - 1: part(i).times = part(i).times - 1
         'if part(i).incredimenty < -part(i).times then part(i).incredimenty = -part(i).times -1: part(i).times = part(i).times - 1
        
        
         part(i).x = part(i).x + part(i).incredimentx
         part(i).y = part(i).y + part(i).incredimenty
        
if part(i).y >= 480 then part(i).incredimenty = -part(i).incredimenty * .5

         'pset (part(i).x, part(i).y), part(i).col
         line(part(i).x,part(i).y)-(part(i).oldx, part(i).oldy),part(i).col
      next

      
   wait &h3da,8
   wait &h3da,8
   sleep 5
   loop until len(inkey$)
Jumping Jahoolipers!
Reply
#9
Very cool.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)