yuppicide Posted November 14, 2008 Share Posted November 14, 2008 (edited) Is it possible to do a command as if pfpixel 31 4 4 on then What I need to do is tell if a pfpixel is on and if so do some other things.. if the pfpixel is off then do nothing. Edited November 14, 2008 by yuppicide Quote Link to comment Share on other sites More sharing options...
jrok Posted November 14, 2008 Share Posted November 14, 2008 (edited) Is it possible to do a command as if pfpixel 31 4 4 on then What I need to do is tell if a pfpixel is on and if so do some other things.. if the pfpixel is off then do nothing. I don't think you can do it like that. As far as I know, "pfpixel [x] [y] on" is actually performing an operation, not testing the state of the pixel. But what you could do is set a variable when the pixel is turned on or off, like: dim pixel_state = a gameloop if [some set of conditions] then pfpixel [x] [y] on : pixel_state=1 if [some other set of conditions] then pfpixel [x] [y] off : pixel_state=0 if pixel_state = 1 then gosub do_some_other_things goto gameloop Edited November 14, 2008 by jrok Quote Link to comment Share on other sites More sharing options...
yuppicide Posted November 14, 2008 Author Share Posted November 14, 2008 (edited) I don't think you can do it like that. As far as I know, "pfpixel [x] [y] on" is actually performing an operation, not testing the state of the pixel. But what you could do is set a variable when the pixel is turned on or off, like: dim pixel_state = a gameloop if [some set of conditions] then pfpixel [x] [y] on : pixel_state=1 if [some other set of conditions] then pfpixel [x] [y] off : pixel_state=0 if pixel_state = 1 then gosub do_some_other_things goto gameloop I don't think I can do what you are saying. I have WAAAAY too many pixels on to make each one a variable. I have most of the screen filled using pfvlines. I can't possibly set variables for 100 or 200 locations. Let's say I have the following as a playfield ********************* *** ***** ** * * *** * You can use your imagination and pretend that it's 32 wide x 11 tall. You can use your imagination and pretend that it's 32 wide x 11 tall. I want to randomly take a number between 1 and 128 (because in that example the tallest piece is 4 tall multiplied by 32 wide is 128) and then see if that pixel is on. Edited November 14, 2008 by yuppicide Quote Link to comment Share on other sites More sharing options...
jrok Posted November 14, 2008 Share Posted November 14, 2008 I don't think you can do it like that. As far as I know, "pfpixel [x] [y] on" is actually performing an operation, not testing the state of the pixel. But what you could do is set a variable when the pixel is turned on or off, like: dim pixel_state = a gameloop if [some set of conditions] then pfpixel [x] [y] on : pixel_state=1 if [some other set of conditions] then pfpixel [x] [y] off : pixel_state=0 if pixel_state = 1 then gosub do_some_other_things goto gameloop I don't think I can do what you are saying. I have WAAAAY too many pixels on to make each one a variable. I have most of the screen filled using pfvlines. I can't possibly set variables for 100 or 200 locations. Let's say I have the following as a playfield ********************* *** ***** ** * * *** * You can use your imagination and pretend that it's 32 wide x 11 tall. You can use your imagination and pretend that it's 32 wide x 11 tall. I want to randomly take a number between 1 and 128 (because in that example the tallest piece is 4 tall multiplied by 32 wide is 128) and then see if that pixel is on. Oh, okay. Well then you can just use pfread to determine the state. That evalutes to true if the pixel is on: So... if pfread(20,46) then gosub do_some_stuff ...would mean "if the playfield pixel at x position 20, y position 46 is on, then do my subroutine." Does that make sense? Cheers, Jarod Quote Link to comment Share on other sites More sharing options...
jrok Posted November 14, 2008 Share Posted November 14, 2008 ...Also, bear in mind that when you are using pfread, you don't have to use static values. You could use variables. So in your case, you'd want to do something like if pfread (my_rand_x,my_rand_y) then gosub do_some_stuff ...where my_rand_x and my_rand_x are the user defined variables that are returned from your random function. So basically, you'll have to build two random functions: one to pick a number between 0 and 31 (the playfield pixel's x position) and one to pick a number between 0 and 11 (the playfield pixel's y position). Then you test those variables with the above statement whenever you want to detect a playfield pixel's state. Jarod Quote Link to comment Share on other sites More sharing options...
yuppicide Posted November 15, 2008 Author Share Posted November 15, 2008 Thanks. SeaGt told me pfread also. I don't know !how! I missed that on the bB Command Reference Page. Quote Link to comment Share on other sites More sharing options...
yuppicide Posted November 15, 2008 Author Share Posted November 15, 2008 How would I do this? if pfread(bloodx,bloody+1) then bloodx = 0 : return I first randomized a number.. that number determines the x and y position of my pfread. If pfread is good then it needs to check the block underneath to see if there is one there or not. Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted November 15, 2008 Share Posted November 15, 2008 (edited) How would I do this? if pfread(bloodx,bloody+1) then bloodx = 0 : return I first randomized a number.. that number determines the x and y position of my pfread. If pfread is good then it needs to check the block underneath to see if there is one there or not. If you're talking about your "tube" playfield, and you want to make the "ceiling" drip randomly, then you can start with y=0, and just pick a random x, maybe sort of like this: playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end COLUPF = $C4 loop drawscreen x = rand x_loop if x > 31 then x = x - 32 : goto x_loop y = 0 y_loop if y > 10 then goto loop if pfread(x,y) then y = y + 1 : goto y_loop if y = 0 then goto loop drip_loop t = y - 1 pfpixel x t off pfpixel x y on drawscreen goto y_loop Michael dripping.bas dripping.bas.bin Edited November 15, 2008 by SeaGtGruff Quote Link to comment Share on other sites More sharing options...
yuppicide Posted November 15, 2008 Author Share Posted November 15, 2008 (edited) While I understand your code I had trouble implementing it into my code. My game works fine, but I can never get it to display any dripping. I set my variables up as bloodx, bloody, and bloodt instead of your x, y, and t. I also have a variable for level. Blood only drips on certain levels. Sent you my current code. Edited November 15, 2008 by yuppicide Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.