Jump to content
IGNORED

pfpixel on question


Retro Lord

Recommended Posts

Yeah I got it working with a random counter. But I suck at math. Player1 is 7 pixels tall and 4 wide. I calculated the x placement perfectly. But I'm having problem wit the y placements. If I want it to go down it's own length 1 time would that be +8 or +9? +7 wasn't quite right it turned out.

Link to comment
Share on other sites

A question about this code again. It appears that it works when player0 is next to the dragon, which is great. But even if player1 is all the way across the playfield and player0 is at the bottom it registers as long as they are nex ´t to each other. How would I fix it so it takes the y value into account aswell?


   if player0x > player1x then _dragon_xpos = player0x - player1x : if _dragon_xpos < 5 then COLUPF=$DA : goto __Skip_Proximity
   if player1x > player0x then _dragon_xpos = player1x - player0x : if _dragon_xpos < 5 then COLUPF=$DA : goto __Skip_Proximity
   if player0y > player1y then _dragon_ypos = player0y - player1y : if _dragon_ypos < 5 then COLUPF=$DA : goto __Skip_Proximity
   if player1y > player0y then _dragon_ypos = player1y - player0y : if _dragon_ypos < 5 then COLUPF=$DA

__Skip_Proximity
Link to comment
Share on other sites

How much have you changed since last time? This is what I did to the last uploaded version:

 

d_and_d_demo_2015y_01m_17d_2303t.bas

 

d_and_d_demo_2015y_01m_17d_2303t.bin

 

I was working on that while you guys were posting back and forth.

Link to comment
Share on other sites

About your last question, try this:

 

   if player0x > player1x then _dragon_xpos = player0x - player1x : if _dragon_xpos < 5 then COLUPF=$DA : goto __Skip_X_Check
   if player1x > player0x then _dragon_xpos = player1x - player0x : if _dragon_xpos < 5 then COLUPF=$DA

__Skip_X_Check

   if player0y > player1y then _dragon_ypos = player0y - player1y : if _dragon_ypos < 5 then COLUPF=$DA : goto __Skip_Proximity
   if player1y > player0y then _dragon_ypos = player1y - player0y : if _dragon_ypos < 5 then COLUPF=$DA

__Skip_Proximity
Link to comment
Share on other sites

Hm, I still get the same problem. I'm thinking it's a math thing. I've fiddled with the numbers and almost got it working once. I'm sure it's this part that needs figuring out what number it needs:

if _dragon_xpos < 4

If I only was better at understanding math

Edited by Retro Lord
Link to comment
Share on other sites

Okay, I've almost fixed it.

This parts now works:

   if player0x > player1x then _dragon_xpos = player0x - player1x : if _dragon_xpos < 8 then COLUPF=$DA : goto __Skip_X_Check
   if player1x > player0x then _dragon_xpos = player1x - player0x : if _dragon_xpos < 5 then COLUPF=$DA

__Skip_X_Check

Now I just have to find the right numbers for the y position

Link to comment
Share on other sites

Well, the issue is that I just can't get the code to do what I want. The 2 first lines are working.(I think) The bottom part not really. What I'm after is, if player1 is either directly left, right, above or below the color change initiates. As it is now the color changes if player0 is left, right, above or below without regard for how close they are too each other.

   if player0x > player1x then _dragon_xpos = player0x - player1x : if _dragon_xpos < 8 then COLUPF=$DA : goto __Skip_Proximity
   if player1x > player0x then _dragon_xpos = player1x - player0x : if _dragon_xpos < 5 then COLUPF=$DA : goto __Skip_Proximity

   if player0y > player1y then _dragon_ypos = player0y - player1y : if _dragon_ypos < 3 then COLUPF=$DA : goto __Skip_Proximity
   if player1y > player0y then _dragon_ypos = player1y - player0y : if _dragon_ypos < 3 then COLUPF=$DA : goto __Skip_Proximity

__Skip_Proximity
Link to comment
Share on other sites

This seems to be working unless I misunderstood:

d_and_d_0.4.1_2015y_01m_18d_0445t.bas

d_and_d_0.4.1_2015y_01m_18d_0445t.bin

Like I had in the other version I posted, the code to place the dragon is fairly small:
_

   ;***************************************************************
   ;
   ;  Sets up random dragon location.
   ;  (_PF_LR and _PF_UD can be used here temporarily because 
   ;  they are set up AFTER this.)
   ;
   _PF_LR = (rand/64) + (rand&3) + (rand/64) + 11
   _PF_UD = (rand/64) + (rand&3) + 2

   player1x = (_PF_LR * 4) + 16
   player1y = (_PF_UD *  + 8

_
Now you don't need all of the if-thens to place the dragon. Here's a test program where you can press reset over and over to see the random placement of the dragon:

reset_test_2015y_01m_18d_0445t.bin

I also put the dims near the beginning of the program so they can be found as quickly and easily as possible. Speaking of dims, if you use dim to make an alias for every variable used in the program, you or anyone editing your program won't have to worry that a variable is already used somewhere deep in the code.

 

 

In case you were wondering, mixing up division and & seems to make the random numbers more spread out and not start in the same place, at least with Stella anyway.

 

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