Jump to content



0

boundaries


10 replies to this topic

#1 esplonky OFFLINE  

esplonky

    Moonsweeper

  • 292 posts
  • Kinetic, Not synthetic.
  • Location:Canyon Lake, TX

Posted Mon May 23, 2011 2:47 PM

i am having trouble. my character goes out of the screen. how do i make a barrier on the outside edge (x=0, y=0 through 88) and then (x=0 through 88, y=0) just the outside pixels.

 
 rem * i like trains
 lives = 128
 dim lives_centered = 1
 dim lives_compact = 1 
 set romsize 4k

titlescreen

 
 scorecolor = $CA
 
 playfield: <on>
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 X.....XXXXXXX..............XX..X
 X..X...XXXXXXXXXXX...XXXXXXXX..X
 X..XX...XXXXXXXXXX...XXXXXXXX..X
 X..XXX...XXXXXXXXX...XXXXXXXX..X
 X..XXXX...XXXXXXXX...XXXXXXXX..X
 X..XXX...XXXXXXXXX...XXXXXXXX..X
 X..XX...XXXXX..XX....XXXXXXXXXXX
 X..X...XXXXXX.......XXXXXXXXX..X
 X.....XXXXXXXX.....XXXXXXXXXX..X
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end
 
 COLUPF = $2E
 COLUBK = $CA

 const pfres = 12

 
 drawscreen
 if joy0fire then goto start
 goto titlescreen
 
start

 playfield:
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
end
 
 COLUBK = $C6
 COLUPF = $3E
 player0x=99:player0y=90
 player1x=20:player1y=20
 missile0height=8:missile0y=255
 NUSIZ0 =  $82
 scorecolor = $0


sprites

   
 player0:
 %00000000
 %01000100
 %01000100
 %01000100
 %01000100
 %00111000
 %00111000
 %00111000
 %00111000
 %00111000
 %00111000
 %00111000
 %00111000
 %11111110
 %10111010
 %10111010
 %10111010
 %00111000
 %00000000
 %00000000
end

 



 player1:
 %00000000
 %00100100
 %00011000
 %00111100
 %00011000
 %00011000
 %00111100
 %00000000
end

 COLUP0 = $84
 COLUP1 = $42
 
 if f=20 then f=0
 if missile0y>240 then goto skip
 missile0y = missile0y-2:goto draw_loop
skip
 if joy0fire then missile0y =  player0y-2:missile0x =player0x+4
 if switchreset then reboot
 

draw_loop
 drawscreen

 if player1y < player0y then player1y = player1y+1
 if player1y > player0y then player1y = player1y-1
 if player1x < player0x then player1x = player1x+1
 if player1x > player0x then player1x = player1x-1
 player1x = player1x:player1y = player1y

 if joy0up then player0y = player0y-1: goto jump
 if joy0down then player0y = player0y+1: goto jump
 if joy0left then player0x = player0x-1: goto jump
 if joy0right then player0x = player0x+1: goto jump

 if collision(missile0,player1) then score=score+1:player1x=rand/2:player1y=0:missile0y=255
 if collision(player0,player1) then lives=lives-32:player1x=rand/2:player1y=0:missile0y=255
 if collision(player1,ball) then score=score+0:player1x=rand/2:player1y=0:bally=255
 if lives < 32 then reboot

jump
 goto sprites


#2 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Mon May 23, 2011 3:37 PM

Skip adjustments if out-of-bounds. Example:

if joy0up && player0y > 0 then player0y = player0y - 1: goto jump

The subtraction does not happen if already at the lowest amount allowed (0 in this case).

#3 esplonky OFFLINE  

esplonky

    Moonsweeper

  • 292 posts
  • Kinetic, Not synthetic.
  • Location:Canyon Lake, TX

Posted Tue May 24, 2011 9:42 AM

where do i put that in my code?

#4 esplonky OFFLINE  

esplonky

    Moonsweeper

  • 292 posts
  • Kinetic, Not synthetic.
  • Location:Canyon Lake, TX

Posted Tue May 24, 2011 9:44 AM

and i want him to not go off the screen, i want like a wall type thing around it

#5 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,545 posts
  • Location:Georgia, USA

Posted Tue May 24, 2011 10:01 AM

View Postesplonky, on Tue May 24, 2011 9:42 AM, said:

where do i put that in my code?
You'd change the existing lines that say "if joy0up" or "if joy0down" and so on. Each of those existing lines would be modified to include the additional checking. As far as *what* additional checking needs to be added, it depends on which direction you're going in and which variable you're changing-- that is, whether you're updating player0x or player0y, and whether you're incrementing it or decrementing it. You want to be sure you don't decrement them past 0, and you want to be sure you don't increment them past the edge of the screen-- 159 for player0x, and I think something like 80 or 88 for player0y.

Michael

#6 esplonky OFFLINE  

esplonky

    Moonsweeper

  • 292 posts
  • Kinetic, Not synthetic.
  • Location:Canyon Lake, TX

Posted Tue May 24, 2011 10:12 AM

english please?

#7 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,921 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Tue May 24, 2011 10:54 AM

I added this to your program based on what has already been posted:

   if joy0up && player0y > 19 then player0y = player0y-1: goto jump
   if joy0down && player0y < 89 then player0y = player0y+1: goto jump
   if joy0left && player0x > 1 then player0x = player0x-1: goto jump
   if joy0right && player0x < 154 then player0x = player0x+1: goto jump


Here's the .bin file to use with an emulator:

Attached File  esplonky_2011y_05m_24d_1238t.bin   4K   30 downloads


Here's the bB code:

Attached File  esplonky_2011y_05m_24d_1238t.bas   2.89K   18 downloads

#8 esplonky OFFLINE  

esplonky

    Moonsweeper

  • 292 posts
  • Kinetic, Not synthetic.
  • Location:Canyon Lake, TX

Posted Tue May 24, 2011 11:22 AM

im just putting this here so i can use my code at school

Attached Files



#9 theloon OFFLINE  

theloon

    Stargunner

  • 1,015 posts

Posted Tue May 24, 2011 8:26 PM

View PostRandom Terrain, on Tue May 24, 2011 10:54 AM, said:

I added this to your program based on what has already been posted:

   if joy0up && player0y > 19 then player0y = player0y-1: goto jump
   if joy0down && player0y < 89 then player0y = player0y+1: goto jump
   if joy0left && player0x > 1 then player0x = player0x-1: goto jump
   if joy0right && player0x < 154 then player0x = player0x+1: goto jump


Here's the .bin file to use with an emulator:

Attachment esplonky_2011y_05m_24d_1238t.bin


Here's the bB code:

Attachment esplonky_2011y_05m_24d_1238t.bas

Very nice start! That enemy sure does lock on to you FAST though!

..and, I'm not sure if I should mention this, but, it looks like your player gets *really* flaccid (right down to his legs!) just before his "missile" detaches itself and unloads onto the enemy.. *cough* Maybe it's just me..

I'd personally start the players, er, "rogue spear" higher up to avoid firing up overactive imaginations :P

Maybe you could start the missile just above the players head so it looks like a laser beam.

Edited by theloon, Tue May 24, 2011 8:36 PM.


#10 esplonky OFFLINE  

esplonky

    Moonsweeper

  • 292 posts
  • Kinetic, Not synthetic.
  • Location:Canyon Lake, TX

Posted Tue May 24, 2011 9:00 PM

ive noticed that, and ive tried to experiment and said "maybe i could make a new custers revenge" so every time his "missile" shot it left a little suprise underneath him lol but i took it out cus i was just messing around with the "ball" script.

#11 esplonky OFFLINE  

esplonky

    Moonsweeper

  • 292 posts
  • Kinetic, Not synthetic.
  • Location:Canyon Lake, TX

Posted Tue May 24, 2011 9:17 PM

so i was messing around with my code and i made my playfield this

 playfield:
 ................................
 .............XX.................
 .............XX.................
 .............XX.................
 .............XX.................
 .............XX.................
 ...........XX..XX...............
 ...........XX..XX...............
 ................................
 ................................
 ................................
end
that would cause major uproar.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users