Jump to content
IGNORED

if pfpixel on?


yuppicide

Recommended Posts

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 by jrok
Link to comment
Share on other sites

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 by yuppicide
Link to comment
Share on other sites

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

Link to comment
Share on other sites

...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

Link to comment
Share on other sites

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 by SeaGtGruff
Link to comment
Share on other sites

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 by yuppicide
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...