Jump to content
IGNORED

Problems with playfield & sprites


STGuy1040

Recommended Posts

I'm having some issues with my first project. I had sprites already working w/ missile sprite but when I added the playfield as an after thought the sprites disappeared. I've been at it for hours and can't seem to figure it out. I also tried adding a title screen (another playfield) for the opening with a pressfire command but that refused to show and work. I'm still new at this so I know it's something I'm doing (or not doing in this case). Here is what I have so far:

 

   set romsize 16kSC
  set kernel_options no_blank_lines

  const pfres=32

  playfield:
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  X..............................X
end

  COLUBK = $00
  COLUPF = $4A

loop
  drawscreen
  goto loop

10 player1x = 40 : player1y = 40:player0x = 50 : player0y = 50
20 COLUPF = 90:missile0height=4:missile0y=255
25 score=10000
30 COLUP0 = 122
35 COLUP1 = 16
40 scorecolor = 10:NUSIZ0=18
45 player0:
 %01000010
 %01000100
 %00100100
 %00011010
 %00011010
 %11111110
 %00011000
 %00111000
end
46 player1:
%001000100
%001000100
%000111000
%010111010
%010111010
%001111100
%001000100
%000111000
end
47 a = a + 1 : if a < 3 then 55
49 a = 0
50 if player1y < player0y then player1y = player1y + 1
51 if player1y > player0y then player1y = player1y - 1
52 if player1x < player0x then player1x = player1x + 1
53 if player1x > player0x then player1x = player1x - 1
54 player1x = player1x : player1y = player1y
55 if missile0y>240 then 58
57 missile0y=missile0y-2:goto 59
58 if joy0fire then missile0y=player0y-2:missile0x=player0x+4
59 drawscreen
60 if collision(missile0,player1) then score=score+1:player1x=rand/2:player1y=0:missile0y=255
65 if collision(player0,player1) then score=score-1
70 if joy0up then player0y = player0y - 1
80 if joy0down then player0y = player0y + 1
100 if joy0left then player0x = player0x - 1
120 if joy0right then player0x = player0x + 1
140 goto 30

 

The playfield in the code currently is where the game will take place. Basically it’s a Robotron clone where enemies attack the player from all angles and player1 starts in the middle. I still need to add animation and directional sprites but that will happen later.

 

Any help you can offer would be greatly appreciated!

Edited by STGuy1040
Link to comment
Share on other sites

In case you don't know, line numbers were mandatory when using old style BASIC languages, but batari Basic is more like later versions of BASIC, so line numbers are no longer necessary. You can use line numbers if you want, but remember to use them like labels instead of putting them at the beginning of every line of code.

 

See Labels and Line Numbers for more information.

 

 

You had a couple of little problems, but the main one was this:

 

loop
  drawscreen
  goto loop

 

You were trapped in a loop with nothing happening. I adjusted your code a bit. Here's my version:

 

 

   set romsize 16kSC
  set kernel_options no_blank_lines
  set smartbranching on

  const pfres=32

gamestart

  playfield:
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  X..............................X
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  X..............................X
end

 player0:
 %01000010
 %01000100
 %00100100
 %00011010
 %00011010
 %11111110
 %00011000
 %00111000
end
 player1:
 %001000100
 %001000100
 %000111000
 %010111010
 %010111010
 %001111100
 %001000100
 %000111000
end

  COLUBK = $00
  COLUPF = $4A

  player1x = 40 : player1y = 40 : player0x = 50 : player0y = 50
  COLUPF = 90 : missile0height=4 : missile0y=255
  score=10000

mainloop
  COLUP0 = 122
  COLUP1 = 16
  scorecolor = 10 : NUSIZ0=18
  a = a + 1 : if a < 3 then 55
  a = 0
  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

55
  if missile0y>240 then 58
  missile0y=missile0y-2 : goto 59

58
  if joy0fire then missile0y=player0y-2:missile0x=player0x+4

59
  drawscreen
  if collision(missile0,player1) then score=score+1:player1x=rand/2:player1y=0:missile0y=255
  if collision(player0,player1) then score=score-1
  if joy0up then player0y = player0y - 1
  if joy0down then player0y = player0y + 1
  if joy0left then player0x = player0x - 1
  if joy0right then player0x = player0x + 1
  if switchreset then gamestart

  goto mainloop

 

Although some might just want to look at your code in your post, it's also helpful if you post your .bas file so people can just download it and start working on it immediately instead of needing to make a blank .bas file, copying your code, and pasting your code.

 

stguy1040_sprites_missing_2008y_11m_05d_0335t.bas

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