IGNORED

# How do I make more sprites?

## Recommended Posts

my_game_in_bas_form.zipI finally figured out how to get the sprite moving. How do I add more? I'd like at minimum 2 more to the left of the first one, and using flashing is fine. Also, how do I add a sound when the game is over?
##### Share on other sites

For starters, people will appreciate it if you keep all your questions in one post, especially if they are similar/the same question, and you are asking them all at more or less the same time.

As for the questions, all I can do is post and describe some examples, but if you start posting code with your questions I can insert them right into your source with comments.

You weren't descriptive at all with your questions either, which is probably why nobody has responded. Are your enemies/obstacles supposed to chase the player, stay on the same vertical line, move randomly, change direction when they hit the edge of the screen or wrap around, etc. If you ask just "How do I move my enemies?" The answer you'll get is:

x=x+1

I CAN answer the multiple enemies question though, with code:

mainloop - the title of your main loop

PLAYER0X = X : PLAYER0Y = Y - the x/y coordinates of the player

PLAYER1X = A : PLAYER1Y = B - the x/y coordinates of the enemies

e = e + 1 - a counter - it adds 1 to e each game loop

if e = 1 then a = 20 - if e is 1, the enemy is shown at vert line 20

if e = 2 then a = 40 - if e is 2, the enemy is shown at vert line 40

if e = 3 then a = 60 : e = 0 - reset the counter after last enemy is shown at vl60

(everything else)

goto mainloop

You now have multiple enemies "flickered" across the screen. To give them each their own vertical movement, each must have their own variable for the y axis (up and down), so the code would change to something like:

b = 30 : c = 40 : d = 50 - y coordinates of each enemy

mainloop - the title of your main loop

PLAYER0X = X : PLAYER0Y = Y - the x/y coordinates of the player

PLAYER1X = A : - the x coordinates of the enemy sprite

e = e + 1 - a counter - it adds 1 to e each game loop

if e = 1 then a = 20 : PLAYER1Y = B - if e is 1, the enemy is shown at vert line 20 and the enemy is shown at hline 30

if e = 2 then a = 40 : PLAYER1Y = C - if e is 2, the enemy is shown at vert line 40, hline 40

if e = 3 then a = 60 : PLAYER1Y = D : e = 0 - reset the counter after last enemy is shown at vl60, hl 50

b = b - 1 : c = c + 1 : d = d + 1 - moves enemy one up 1pixel each loop, enemy 2 & 3 down one each loop.

(everything else)

goto mainloop

##### Share on other sites

For starters, people will appreciate it if you keep all your questions in one post, especially if they are similar/the same question, and you are asking them all at more or less the same time.

As for the questions, all I can do is post and describe some examples, but if you start posting code with your questions I can insert them right into your source with comments.

You weren't descriptive at all with your questions either, which is probably why nobody has responded. Are your enemies/obstacles supposed to chase the player, stay on the same vertical line, move randomly, change direction when they hit the edge of the screen or wrap around, etc. If you ask just "How do I move my enemies?" The answer you'll get is:

x=x+1

I CAN answer the multiple enemies question though, with code:

mainloop - the title of your main loop

PLAYER0X = X : PLAYER0Y = Y - the x/y coordinates of the player

PLAYER1X = A : PLAYER1Y = B - the x/y coordinates of the enemies

e = e + 1 - a counter - it adds 1 to e each game loop

if e = 1 then a = 20 - if e is 1, the enemy is shown at vert line 20

if e = 2 then a = 40 - if e is 2, the enemy is shown at vert line 40

if e = 3 then a = 60 : e = 0 - reset the counter after last enemy is shown at vl60

(everything else)

goto mainloop

You now have multiple enemies "flickered" across the screen. To give them each their own vertical movement, each must have their own variable for the y axis (up and down), so the code would change to something like:

b = 30 : c = 40 : d = 50 - y coordinates of each enemy

mainloop - the title of your main loop

PLAYER0X = X : PLAYER0Y = Y - the x/y coordinates of the player

PLAYER1X = A : - the x coordinates of the enemy sprite

e = e + 1 - a counter - it adds 1 to e each game loop

if e = 1 then a = 20 : PLAYER1Y = B - if e is 1, the enemy is shown at vert line 20 and the enemy is shown at hline 30

if e = 2 then a = 40 : PLAYER1Y = C - if e is 2, the enemy is shown at vert line 40, hline 40

if e = 3 then a = 60 : PLAYER1Y = D : e = 0 - reset the counter after last enemy is shown at vl60, hl 50

b = b - 1 : c = c + 1 : d = d + 1 - moves enemy one up 1pixel each loop, enemy 2 & 3 down one each loop.

(everything else)

goto mainloop

Why I started another post is because I solved the first problem, and needed a second one solved. As for the enemies, I wanted them to be just like the first one. I thought the .bas file would explain what I wanted them to do. And second of all, I'm a newbie in the Atari 2600 BASIC programming, and especially to this forum, and I don't know how to delete a post, and I checked the FAQ and everything. Here's the code, anyway:

c - counter for lives, x - player0x position, y - player0y position, w - player1x position, v - player 1y position.

-

1 rem : "I Like Bacon" programmed by Chris Read...

2 set smartbranching on

4 score = 0 : c = 4

5 x = 160 : y = 50

7 scorecolor = 68

9 AUDC0 = 0

14 COLUPF = 136

20 goto 40

35 score = score + 1

36 x = 160

40 COLUP0 = 38 : player0x = x : player0y = y

if c=0 then goto 500

50 COLUBK = 186

60 player0:

%10001

%01010

%00100

%11111

%00100

%01110

%01010

%01110

end

110 w = 140

111 v = v + 9

112 w = w - 1

114 if switchreset then goto 1

116 if w < 10 then goto 110

118 player1x = w

120 player1y = v

140 player1:

%1010101

%1111111

%1111111

%1111111

%1101011

%0111110

%0011100

end

188 drawscreen

189 AUDV0 = 0

190 if joy0left then x = x - 1

if x<100 then x=160

if x=100 then AUDV0 = 24 : AUDC0 = 12 : AUDF0 = 3 : goto 35

200 if collision(player0,player1) then c=c-1 : AUDV0 = 24: AUDF0 = 7 : AUDC0 = 1 : x = 160 : y = 50 : goto 40

220 goto 40

500 v = 12 : w = 100 : AUDV0 = 12 : AUDC0 = 8 : AUDF0 = 14

502 drawscreen

505 COLUBK = 212

510 if !switchreset then goto 500

-

Could you please but example #2 into the code I just posted?

As for the enemy sprites moving, I meant really move them. I finally did it by copying some code from another basic game into lines 110-120.

Edited by atari2600land
##### Share on other sites

Line 110 sets w to 140

Line 112 subtracts one making w 139

If this serves a point in your mind, you aren't understanding the language at all. If you just read the help.html file that comes with bB, you'll get somewhere a lot faster.

##### Share on other sites

Line 110 sets w to 140

Line 112 subtracts one making w 139

If this serves a point in your mind, you aren't understanding the language at all. If you just read the help.html file that comes with bB, you'll get somewhere a lot faster.

I thought I could do it by myself cuz I made some programs with a TI84+, that and I made some programs with Q-Basic, but I guess I really need to delve into how to program with Basic. Problem is, I'm more of an example-viewing learner than a read-a-bunch-of-words learner, so that's why I posted some code from another game in here and tweaked it to fit my own. And I read most of the help.html file, which is how I got colors, player0 and player1 sprites on the screen in the first place, the sounds, and a bunch of other stuff in there. The lives thing I learned from the TI-84+ programming I've done. I thought that TI-84+ Basic would be just about the same as Atari Basic, but I guess I was wrong.

##### Share on other sites

You are definately off to a good start if you were able to put together a working game that compiles. Since you already have some experience with BASIC, you should be able to use your trial and error method to pick this version up pretty quick. The source I've attached does the same thing as yours (minus sound), so you should be able to see from the comments what each line is doing and why I made the changes I did. Good luck finishing the game and if you have any other questions you should post them, the people who post here are very friendly and helpful; including the creator of bB.

paccityremix.bas

Edited by MausBoy
##### Share on other sites

You are definately off to a good start if you were able to put together a working game that compiles. Since you already have some experience with BASIC, you should be able to use your trial and error method to pick this version up pretty quick. The source I've attached does the same thing as yours (minus sound), so you should be able to see from the comments what each line is doing and why I made the changes I did. Good luck finishing the game and if you have any other questions you should post them, the people who post here are very friendly and helpful; including the creator of bB.

Thanks for helping, MausBoy - I don't always have time to field all of the questions.

To atari2600land: I went ahead and removed the duplicate posts for you. BTW - most people learn programming by looking at others' code, but right now the code is kind of scattered around. I do intend to create a code repository someday that contains a bunch of bB code all in one place - maybe I'll get to it this summer. For now, take a look at the code posted to the forums and some of the examples included with bB itself.

##### Share on other sites

Thanx you guys. A code list would be wonderful for newbies who learn quickly like me. You tell me when it's done, OK? I'll try to be more specific with my questions. I think I'll have a couple more as I'm finishing this game up.

##### Share on other sites

Before the replies, I worked a little bit more on the game. Here's the code I revised:

----

1 rem : "I Like Bacon" programmed by Chris Read...

2 set smartbranching on

4 score = 0 : c = 4

5 x = 160 : y = 50

7 scorecolor = 30

9 AUDC0 = 0

14 COLUPF = 136

20 goto 40

35 score = score + 1

36 x = 160

40 COLUP0 = 38 : player0x = x : player0y = y

if c=0 then goto 500

50 COLUBK = 200

60 player0:

%10001

%01010

%00100

%11111

%00100

%01110

%01010

%01110

end

110 w = 140

111 v = v + 9

114 if switchreset then goto 1

116 if w < 10 then goto 110

121 e=e+1

122 if e=1 then w=110

123 if e=2 then w=80

124 if e=3 then w=50 : e=0

125 player1x = w

126 player1y = v

127 COLUP1 = 70

140 player1:

%00100

%01110

%11111

%11111

%11111

%11111

%11111

end

188 drawscreen

189 AUDV0 = 0

190 if joy0left then x = x - 1

if x<40 then x=160

if x=40 then AUDV0 = 24 : AUDC0 = 12 : AUDF0 = 3 : goto 35

200 if collision(player0,player1) then c=c-1 : AUDV0 = 24: AUDF0 = 7 : AUDC0 = 1 : x = 160 : y = 50 : goto 40

220 goto 40

500 v = 12 : w = 100 : AUDV0 = 12 : AUDC0 = 8 : AUDF0 = 14

502 drawscreen

505 COLUBK = 212

510 if !switchreset then goto 500

----

In paccityremix.bas, when I compiled and ran it, the hit detection seemed a little off. It looks like player0 (me) took a free hit before player1 (enemy) hit it.

Anyway, I was able to input the new colors and new enemy sprite into paccityremix.bas, but was unable to figure out where to put the second example, or the sounds. Here's the sfxs I wanted (but you probably knew them if you read this code:..)

Game Over: AUDV0 = 12 AUDC0 = 8 AUDF0 = 14

Getting Hit: AUDC0 = 1 AUDF0 = 7

Making it across: making it across : AUDC0 = 12 : AUDF0 = 3

I changed the volume for the getting hit and making it across noises cuz i couldn't hear them. If they aren't a constant never-ending stop, I'd like them to be 12 also.

Here's what I updated from paccityremix.bas

----

rem PLAYER/ENEMY SPRITES

player0:

%10001

%01010

%00100

%11111

%00100

%01110

%01010

%01110

end

player1:

%00100

%01110

%11111

%11111

%11111

%11111

%0011100

end

rem - changed player1 sprite

rem SET PLAYFIELD COLOR

COLUPF = 136

rem SET PLAYER/ENEMY/BACKGROUND COLORS

COLUP0 = 38 : COLUP1 = 33 : COLUBK = 200

----

I also changed the scorecolor and i wrote new death code (lines 500 and after on the old updated code) and i tried incorporating that into paccityremix.bas, but i was unsuccessful. All I need to do to finish this is put in the new death sequence, the new sprites with moving patterns seperate than the first (farthest right) one, & the sounds (and make the hit detection better if possible.) If it's not too much trouble, could someone do this for me, because as I said, I'm a newbie. If you don't want to, I'll understand and keep plugging away at this.

##### Share on other sites

If you read through the code and follow the C variable, you'll see what is going on with player/enemy collisions. C starts out as 4, and 1 is subtracted with each collision. If C reaches zero the game resets. I thought a delayed death was what you were going for, possibly to add some kind of health bar or something. Anyway, you have to be able to understand how the variables are working and basic program structure to be able to add the things you mentioned.

##### Share on other sites

example #2 showed me how I can have 3 sprites be in different places while standing still. Can they be in different places while falling, like sprite 1 falling before sprite 2, etc.?

##### Share on other sites

example #2 gives each enemy it's own vertical variable. That means they can move in different directions at different speeds by adding and subtracting from those variables. The example does this by the way; one moves up and down the screen, two move down and up, and they all start at different vertical positions. Once you have a little more experience you'll see how to make them start there movement at different times using variables as well. What you'll need is called a "flag", for example once enemy 1 reaches the bottom of the screen, a flag is set telling enemy #2 it's time to start moving. Or you can use a counter, then say when it reaches 20 enemy 1 starts moving, reaches 50 enemy 2 starts moving, etc.

Edited by MausBoy

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.