 |
|
| View previous topic :: View next topic |
| Author |
Message |
Master of C64


Joined: 06 Aug 2008 Age: 29 Posts: 1317 Location: Bristol, UK
|
Posted: Tue Jun 19, 2012 9:32 pm Post subject: Joystick program |
|
|
I have a working program for joystick control over sprite 0. I have added these joystick control lines to the end of my program. Before adding this I would have sprite 0 sat stationary (waiting for joystick control) and sprite 1 moving from left-right in a loop. However, since adding these lines for joystick control the loop lasts a few seconds -stops-a symbol appears at top right of screen and then sprite 0 becomes controllable? What I was hoping for was to move sprite 0 with joystick as well as sprite 1 still moving in its loop from left-right?
What is going on?
Cheers
Jamie |
|
| Back to top |
|
 |
Immortal Grandmaster of C64


Joined: 30 Apr 2009 Age: 38 Posts: 3463 Location: Sweden
|
Posted: Tue Jun 19, 2012 10:20 pm Post subject: |
|
|
Sounds a bit difficult to know without seeing some code.
I'm guessing you made a mistake...  |
|
| Back to top |
|
 |
Master of C64


Joined: 06 Aug 2008 Age: 29 Posts: 1317 Location: Bristol, UK
|
Posted: Wed Jun 20, 2012 8:24 am Post subject: |
|
|
lol I can show my code later today. |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Wed Jun 20, 2012 10:22 am Post subject: |
|
|
What you have to do is put the joystick/sprite moving code INSIDE the loop that moves your sprite...
After moving the sprite that moves back and forth, check the joystick and depending on the outcome, move the other sprite.
Then loop...
And as e5frog says: showing code tells more than a 1000 words  |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Wed Jun 20, 2012 10:32 am Post subject: Re: Joystick program |
|
|
| Commodoresales wrote: | | ... the loop lasts a few seconds -stops-a symbol appears at top right of screen and then ... |
Can be caused by a POKE to a (wrong) memory location in screen-ram. |
|
| Back to top |
|
 |
Master of C64


Joined: 06 Aug 2008 Age: 29 Posts: 1317 Location: Bristol, UK
|
Posted: Wed Jun 20, 2012 10:39 am Post subject: |
|
|
| Mogwai wrote: | What you have to do is put the joystick/sprite moving code INSIDE the loop that moves your sprite...
After moving the sprite that moves back and forth, check the joystick and depending on the outcome, move the other sprite.
Then loop...
And as e5frog says: showing code tells more than a 1000 words  |
Loop that moves my sprite? Would that be "V+2,100+X:POKEV+3,100" This is followed by "Next X:". which proceeds to "Goto 145" Which then "FOR X=1 TO 100" So I am guessing this is the loop?
I am taking this project very slowly - I am learning as I go and feel that I have learned so much in the past week. Feels good! |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Wed Jun 20, 2012 11:05 am Post subject: |
|
|
Yep. Insert your joystick code between "Poke V+2,100+X:POKEV+3,100" and "Next X"
And like I said before: no need to put the "POKEV+3,100" in the loop: since the y-coordinate doesn't change at the moment, you don't have to update it every iteration of the loop.
Another warning: be careful not to modify 'X'!!!
Use different variables for the coordinates of the joystick controlled sprite. |
|
| Back to top |
|
 |
Master of C64


Joined: 06 Aug 2008 Age: 29 Posts: 1317 Location: Bristol, UK
|
Posted: Wed Jun 20, 2012 11:08 am Post subject: |
|
|
Nice one - told you! I must be programming as an amateur - I knew where the loop was
I will check that out tonight when our kid is in bed.
Cheers buddy! |
|
| Back to top |
|
 |
Master of C64


Joined: 06 Aug 2008 Age: 29 Posts: 1317 Location: Bristol, UK
|
Posted: Wed Jun 20, 2012 7:27 pm Post subject: |
|
|
| Mogwai wrote: | Yep. Insert your joystick code between "Poke V+2,100+X:POKEV+3,100" and "Next X"
And like I said before: no need to put the "POKEV+3,100" in the loop: since the y-coordinate doesn't change at the moment, you don't have to update it every iteration of the loop.
Another warning: be careful not to modify 'X'!!!
Use different variables for the coordinates of the joystick controlled sprite. |
I just typed everything up on a notepad (not tested on real 64 yet). Hopefully everything within the lines and the structure of it is good. At some point I am planning to change sprite 1 (enemy sprite) to something different!
Here it is:
100 PRINTCHR$(147): REM CLEARS SCREEN
110 V=53248: REM ENABLES VIC CHIP
115 POKE 2041,13: REM SPRITE 1 DATA IS AT 13*64
116 POKE 2042,14; REM SPRITE 2 DATA IS AT 14*64
117 FOR G = O TO 62:READ H:POKE 832+G,H:NEXT G:REM FILL SPRITE 1
118 FOR G = 0 TO 62:READ H:POKE 896+G,H:NEXT G:REM FILL SPRITE 2
120 POKE V+21,2+4:REM ENABLE SPRITES 1 + 2(2+4)
121 POKE V+40,7:REM COLOR FOR SPRITE 1
122 POKE V+41,8:REM COLOR FOR SPRITE 2
125 FOR X = 1 TO 100
130 POKE V+2,100+X:POKE V+3,100:REM X AND Y POSITION FOR SPRITE 1
299 REM: JOYSTICK CONTROL
300 J = 255-PEEK(56320)
310 IF J AND 1 THEN GOSUB 500
330 IF J AND 2 THEN GOSUB 520
340 IF J AND 4 THEN GOSUB 540
350 IF J AND 8 THEN GOSUB 560
360 J = 255-PEEK(56321)
370 IF J AND 1 THEN GOSUB 500
380 IF J AND 2 THEN GOSUB 520
390 IF J AND 4 THEN GOSUB 540
395 IF J AND 8 THEN GOSUB 560
398 GOTO 300
500 IF PEEK (V+3)>80 THEN POKE V+3,PEEK(V+3)-1
510 RETURN
520 IF PEEK (V+2)>200 THEN POKE V+3,PEEK(V+3)+1
530 RETURN
540 IF PEEK (V+2)>80 THEN POKE V+2,PEEK(V+2)-1
550 RETURN
560 IF PEEK (V+2)<250 THEN POKE V+2,PEEK(V+2)+1
570 RETURN
600 POKE V+4,200-X:POKE v+5,100:REM X AND Y POSITION FOR SPRITE 2
610 NEXT X:
620 POKE (V+40),(15-(PEEK(V+40)AND15)):REM MOVES SPRITES ON TOP EACH OTHER
630 POKE (V+41),(15-(PEEK(V+41)AND15)):REM MOVES SPRITES ON TOP EACH OTHER
640 GOTO 125
645 REM: SPRITE 0 DATA
650 DATA 0,0,0,0,0,0
655 DATA 0,0,0,0,0,55
660 DATA 0,3,48,0,2,48
665 DATA 0,3,55,0,15,254
670 DATA 0,3,251,0,3,251
680 DATA 0,15,254,0,3,55
685 DATA 0,2,48,0,3,48
690 DATA 0,0,55,0,0,0
695 DATA 0,0,0,0,0,0,0,0
700 DATA 0,0,0,0,0,0,0
701 REM: SPRITE 1 DATA
705 DATA 0,0,0,0,0,0
710 DATA 0,0,0,0,0,55
715 DATA 0,3,48,0,2,48
720 DATA 0,3,55,0,15,254
725 DATA 0,3,251,0,3,251
730 DATA 0,15,254,0,3,55
735 DATA 0,2,48,0,3,48
740 DATA 0,0,55,0,0,0
745 DATA 0,0,0,0,0,0,0,0
750 DATA 0,0,0,0,0,0,0 |
|
| Back to top |
|
 |
Forum Junkie

Joined: 17 Jun 2006 Posts: 527
|
Posted: Thu Jun 21, 2012 4:52 am Post subject: |
|
|
| Commodoresales wrote: | 500 IF PEEK (V+3)>80 THEN POKE V+3,PEEK(V+3)-1
510 RETURN
520 IF PEEK (V+2)>200 THEN POKE V+3,PEEK(V+3)+1
530 RETURN
540 IF PEEK (V+2)>80 THEN POKE V+2,PEEK(V+2)-1
550 RETURN
560 IF PEEK (V+2)<250 THEN POKE V+2,PEEK(V+2)+1
570 RETURN |
There is something wrong here. line 520 deals with v+2 AND v+3. Both 500 and 540 do a > 80.
I would recommend you keep the sprite location in a variable(or maybe an array). Then poke that into the sprite location. This will save you from doing peeks. And it makes it easier if you ever want to deal the 255 barrier. _________________
|
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Thu Jun 21, 2012 8:06 am Post subject: |
|
|
| Commodoresales wrote: | | Code: |
....
395 IF J AND 8 THEN GOSUB 560
398 GOTO 300
500 IF PEEK (V+3)>80 THEN POKE V+3,PEEK(V+3)-1
510 RETURN
520 IF PEEK (V+2)>200 THEN POKE V+3,PEEK(V+3)+1
530 RETURN
540 IF PEEK (V+2)>80 THEN POKE V+2,PEEK(V+2)-1
550 RETURN
560 IF PEEK (V+2)<250 THEN POKE V+2,PEEK(V+2)+1
570 RETURN
600 POKE V+4,200-X:POKE v+5,100:REM X AND Y POSITION FOR SPRITE 2
610 NEXT X:
620 POKE (V+40),(15-(PEEK(V+40)AND15)):REM MOVES SPRITES ON TOP EACH OTHER
630 POKE (V+41),(15-(PEEK(V+41)AND15)):REM MOVES SPRITES ON TOP EACH OTHER
640 GOTO 125
...
|
|
Perhaps you've already debugged this code, perhaps not. Here my 2 cents:
Apart from other (typo) errors like comparisons and x,y addresses in lines 500-570, the Goto in line 398 will cause an endless loop in which you can move the 2nd sprite, but the 1st one is now frozen: line 600 and onwards will never be executed.
The GOTO should jump to line 610, so the 1st sprite gets moved.
Line 600 that sets the position of sprite 2 is no longer necessary: that gets done in lines 500-570 of your code.
As you can see from examining lines 600 and 500-570, the addresses you use for the 2nd sprite are not correct.
Then lines 620 and630 can be omitted, they were a trick I added in your previous thread, and are no longer applicable in this scenario.
Also, like THEWIZ wrote: keep track of the x, y coordinates in a variable.
Peeking them adds overhead and will overcomplicate things for x-positions bigger than 255! |
|
| Back to top |
|
 |
Immortal Grandmaster of C64


Joined: 30 Apr 2009 Age: 38 Posts: 3463 Location: Sweden
|
Posted: Thu Jun 21, 2012 12:08 pm Post subject: |
|
|
Where are you doing the programming?
In VICE you can copy and paste code directly to the reply-window.
Here's how 520 is supposed to look:
| Code: | break in 330
ready.
lI 520
520 if peek (v+3)<200 then poke v+3,peek
(v+3)+1
ready. |
|
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Thu Jun 21, 2012 1:23 pm Post subject: |
|
|
| e5frog wrote: | Where are you doing the programming?
In VICE you can copy and paste code directly to the reply-window.
Here's how 520 is supposed to look:
| Code: | break in 330
ready.
lI 520
520 if peek (v+3)<200 then poke v+3,peek
(v+3)+1
ready. |
|
Yup, you correctly identified the typos I hinted at
Now all he has to do is fix it so that sprite 2 moves by joystick and sprite 1 by means of the for-loop. |
|
| Back to top |
|
 |
Grandmaster of C64


Joined: 29 Jun 2009 Age: 40 Posts: 2615 Location: Baltimore, MD Favorite Games: Ultima ][, Wasteland
|
Posted: Thu Jun 21, 2012 5:44 pm Post subject: |
|
|
Didn't like how sprite two wasn't controlled. Besides the typos and adding 5frog's fix, I expanded the play area, re-did the for loop, added the sprite 2 back which was at the end of the for loop and since you are not taking the sprite all the way across the screen drew a quick border which on the right side you could keeps scores, name of the game, etc...
| Code: | 100 rem draw board
101 printchr$(147)" "chr$(161)
104 forx=1to23
105 print" "chr$(161)
106 next x
107 print" "chr$(161)chr$(19)
110 v=53248: rem enables vic chip
115 poke 2041,13: rem sprite 1 data is at 13*64
116 poke 2042,14: rem sprite 2 data is at 14*64
117 for g = 0 to 62:read h:poke 832+g,h:next g:rem fill sprite 1
118 for g = 0 to 62:read h:poke 896+g,h:next g:rem fill sprite 2
120 poke v+21,2+4:rem enable sprites 1 + 2(2+4)
121 poke v+40,7:rem color for sprite 1
122 poke v+41,8:rem color for sprite 2
125 for x = 1 to 240
130 poke v+2,15+x:poke v+3,100:rem x and y position for sprite 1
140 poke v+4,15+x:poke v+5,180:rem x and y position for sprite 2
150 next x
299 rem: joystick control 1
300 j = 255-peek(56320)
310 if j and 1 then gosub 400
330 if j and 2 then gosub 420
340 if j and 4 then gosub 440
350 if j and 8 then gosub 460
355 rem: joystick control 2
360 k = 255-peek(56321)
370 if k and 1 then gosub 500
380 if k and 2 then gosub 520
390 if k and 4 then gosub 540
395 if k and 8 then gosub 560
398 goto 300
400 if peek (v+5)>49 then poke v+5,peek(v+5)-1
410 return
420 if peek (v+5)<234 then poke v+5,peek(v+5)+1
430 return
440 if peek (v+4)>13 then poke v+4,peek(v+4)-1
450 return
460 if peek (v+4)<255 then poke v+4,peek(v+4)+1
470 return
500 if peek (v+3)>49 then poke v+3,peek(v+3)-1
510 return
520 if peek (v+3)<234 then poke v+3,peek(v+3)+1
530 return
540 if peek (v+2)>13 then poke v+2,peek(v+2)-1
550 return
560 if peek (v+2)<255 then poke v+2,peek(v+2)+1
570 return
645 rem: sprite 1 data
650 data 0,0,0,0,0,0
655 data 0,0,0,0,0,55
660 data 0,3,48,0,2,48
665 data 0,3,55,0,15,254
670 data 0,3,251,0,3,251
680 data 0,15,254,0,3,55
685 data 0,2,48,0,3,48
690 data 0,0,55,0,0,0
695 data 0,0,0,0,0,0,0,0
700 data 0,0,0,0,0,0,0
701 rem: sprite 2 data
705 data 0,0,0,0,0,0
710 data 0,0,0,0,0,55
715 data 0,3,48,0,2,48
720 data 0,3,55,0,15,254
725 data 0,3,251,0,3,251
730 data 0,15,254,0,3,55
735 data 0,2,48,0,3,48
740 data 0,0,55,0,0,0
745 data 0,0,0,0,0,0,0,0
750 data 0,0,0,0,0,0,0
|
Paste into vice and type run once it finishes pasting.
P.S.
I recommend blitzing it when you are done with it to make it move faster since at the current speed it is dog slow. _________________
|
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Thu Jun 21, 2012 9:16 pm Post subject: |
|
|
Before 'Blitzing', It already can be optimized a lot:
- Don't poke the Y position of the horizontally moving sprite(s) every iteration.
- Why check both joysticks?
- When checking only one joystick: no need for gosubs!
- When joystick left is detected, forget about checking right: cannot happen
- Same for Up vs down.
- Store x,y in variables, use those for range check and poke once.
Cheers! |
|
| Back to top |
|
 |
Immortal Grandmaster of C64


Joined: 30 Apr 2009 Age: 38 Posts: 3463 Location: Sweden
|
Posted: Fri Jun 22, 2012 12:18 am Post subject: |
|
|
As the guy tries to learn something it's perhaps better to come with hints than to solve the whole problem...
Try and write as little code as possible in the loop, then there are some rules to follow when writing in BASIC that helps speed things up. Don't remember all of them but for example all spaces can be removed. When done programming renumber everything starting with 0 and increase with one. Gosub is slow in BASIC, I think it starts searching for the right address from the beginning of the program - or perhaps that was DATA...
You can google for this if you like...
Using variables is always faster than numbers, so C = A + B is faster than C = 1 + 2. Remove REM - anything that makes the listing longer in amount of bytes decreases the performance so also use as few line numbers as possible. Single character variables first - to shorten listing. If you want to cram in as much as possible on a row use abbreviations of commands like ? for print, pO for poke...
Don't know how much it matters, it's of course better to write it in assembler as you soon realize if you need some speed. Compiling the BASIC program as suggested will of course also help.
If you are going to use the same sprite for both objects, just poke 2041,13 and 2042,13 - no need to read it in twice. I understand that you possibly want to change it later.
Here's an example of shorter code, it can be handy to have stuff in a constant/variable so you can change the appearance of several things with a single change.
| Code: | 0v=53248:z=56320:c=z+1:f=255:q=v+2:w=v+3:e=v+4:r=v+5:t=15:y=100:u=15:i=180:m=4
1a=49:s=234:d=13:b=1:printchr$(147)" "chr$(161)
2o=2:l=4:n=8:forx=1to23:print" "chr$(161):nextx
3print" "chr$(161)chr$(19):poke2041,13
4poke2042,13:forg=0to62:readh:poke832+g,h:nextg:pokev+21,2+4:pokev+40,7
5pokev+41,8:poker,i:pokew,y:forx=1to240:t=t+1:u=t:pokeq,t:pokee,u:nextx
7j=f-peek(z):k=f-peek(c)
8ifjandbtheni=i-m:ifi<atheni=a:goto10
9ifjandotheni=i+m:ifi>stheni=s
10poker,i:ifjandlthenu=u-m:ifu<dthenu=d:goto12
11ifjandnthenu=u+m:ifu>fthenu=f
12pokee,u:ifkandbtheny=y-m:ify<atheny=a:goto14
13ifkandotheny=y+m:ify>stheny=s
14pokew,y:ifkandlthent=t-m:ift<dthent=d:goto16
15ifkandnthent=t+m:ift>fthent=f
16pokeq,t:goto7
17data,,,,,,,,,,,55,,3,48,,2,48,,3,55,,15,254,,3,251,,3,251,,15,254,,3,55
18data,2,48,,3,48,,,55,,,,,,,,,,,,,,,,,,,
|
It gets very cryptic...
No need to write 0:s in the data, comma is enough.
Speed is set on variable m, boundary on a,s,d and I borrowed f as it was the right number already. For ease it should be a variable of its own.
Not sure if it's possible to code the joystick reading and two sprite coordinates a whole lot faster in basic...
 |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Fri Jun 22, 2012 6:46 am Post subject: |
|
|
| e5frog wrote: | As the guy tries to learn something it's perhaps better to come with hints than to solve the whole problem...  |
Exactly why I didn't post any code, and hints only...
You seem to be breaking your own 'rule' by the way  |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Fri Jun 22, 2012 7:12 am Post subject: |
|
|
| e5frog wrote: | Not sure if it's possible to code the joystick reading and two sprite coordinates a whole lot faster in basic...  |
You could optimize this a bit:
| Code: | 0 ..... :t=15:.......
5 .... forx=1to240:t=t+1:u=t:pokeq,t:pokee,u:nextx ... |
into:
| Code: | Remove t=15 from line 0
5 .... fort=16to255:pokeq,t:pokee,t:nextt: u=t ...
|
|
|
| Back to top |
|
 |
Immortal Grandmaster of C64


Joined: 30 Apr 2009 Age: 38 Posts: 3463 Location: Sweden
|
Posted: Fri Jun 22, 2012 9:04 am Post subject: |
|
|
I only shortened mistermsk's code.
Yes, that would help a little, believe I didn't change row five until afterwards, initial declaration of u could be removed as well... Declaration is not needed at all in many cases...
There's probably a lot more that can be done if you're used to this kind of thing. |
|
| Back to top |
|
 |
Grandmaster of C64


Joined: 29 Jun 2009 Age: 40 Posts: 2615 Location: Baltimore, MD Favorite Games: Ultima ][, Wasteland
|
Posted: Fri Jun 22, 2012 12:28 pm Post subject: |
|
|
Runs a lot smoother. Just need firing and sprite collisions. Also, possible asteroids from the left and a scoring system. Besides a name. Since it was Commodoresales who originally wrote it, it could be Commodore: On The Way Back Up. The Sprites could be Commodore symbols and, instead of asteroids, could be Apple and Atari logs you have to shoot and money as power-ups.  _________________ |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Fri Jun 22, 2012 12:51 pm Post subject: |
|
|
Hi..
Already sent a copy of my adaptation of this program to e5frog...
After some discussion about speeding up and performance, I tweaked it a bit. Here is the optimized version:
| Code: | 0GOSUB8
1POKEV2,X1:POKEV4,X2:POKEV5,Y2:X1=X1+DX:IF((X1=LE)OR(X1=RE))THENDX=-DX
2J=FF-PEEK(JR):IFJANDB1THENY2=Y2-SZ:IFY2<TPTHENY2=TP:GOTO4
3IFJANDB2THENY2=Y2+SZ:IFY2>BTTHENY2=BT
4IFJANDB4THENX2=X2-SZ:IFX2<LTTHENX2=LT:GOTO6
5IFJANDB8THENX2=X2+SZ:IFX2>RTTHENX2=RT
6IFJANDB6THENpokeSC,WH:pokeSC,BL
7GOTO1
8V=53248:V2=V+2:V4=V+4:V5=V+5:PRINTCHR$(147):poke53280,0:poke53281,0:JR=56320
9FF=255:SC=53281:WH=1:BL=0:SZ=2:LT=80:RT=250:TP=80:BT=200:LE=100:RE=200:B1=1
10B2=2:B4=4:B8=8:B6=16:POKE2041,13:POKE2042,14:FORG=832TO894:READH:POKEG,H:NEXT
11FORG=896TO958:READH:POKEG,H:NEXT:POKEV+21,2+4:POKEV+40,7:POKEV+41,1
12POKEV+3,100:X2=172:Y2=200:X1=100:DX=1:RETURN
13DATA,,,,,,,,,,,55,,3,48,,2,48,,3,55,,15,254,,3,251,,3,251,,15,254,,3,55,,2,48
14DATA,3,48,,,55,,,,,,,,,,,,,,,,,,,,16,,,16,,,16,,,56,,,40,,,40,,,40,,,108,,69
15DATA215,68,71,215,196,95,69,244,124,198,124,127,199,252,127,199,252,68,68,68
16DATA64,84,4,,214,,,146,,1,255,,,56,,,16, |
2 different sprites, 'AI' for the top ship, only one joystick supported in port 2, but you can press fire!
Full version, including clarifying REM's available on request  |
|
| Back to top |
|
 |
Forum Junkie

Joined: 15 Feb 2003 Posts: 530 Location: Manitoba, Canada
|
Posted: Fri Jun 22, 2012 1:28 pm Post subject: |
|
|
 This is a fun thread to read. Breaking this down into components, it looks like it would be fairly easy to convert to ML. _________________ Proud Canuck and user of C64 systems since 1985. |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Fri Jun 22, 2012 1:46 pm Post subject: |
|
|
| qaz112 wrote: | This is a fun thread to read. Breaking this down into components, it looks like it would be fairly easy to convert to ML. |
Is this a cunningly worded request?  |
|
| Back to top |
|
 |
Über Groupie


Joined: 20 Oct 2011 Age: 48 Posts: 342 Location: Netherlands
|
Posted: Fri Jun 22, 2012 2:03 pm Post subject: |
|
|
| mistermsk wrote: | Runs a lot smoother. Just need firing and sprite collisions. Also, possible asteroids from the left and a scoring system. Besides a name. Since it was Commodoresales who originally wrote it, it could be Commodore: On The Way Back Up. The Sprites could be Commodore symbols and, instead of asteroids, could be Apple and Atari logs you have to shoot and money as power-ups.  |
the 3-time repetition of a lot of spaces between quotes in the shortened version irked me.
See here a slightly smaller version using a string variable.
result: the program is 1 line shorter: line 3 is gone!
| Code: | 0v=53248:z=56320:c=z+1:f=255:q=v+2:w=v+3:e=v+4:r=v+5:y=100:i=180:m=4
1a=49:s=234:d=13:b=1:printchr$(147);:a$=" "
2a$=a$+chr$(161):o=2:l=4:n=8:forx=1to24:printa$:nextx:printa$;:poke2041,13
4poke2042,13:forg=0to62:readh:poke832+g,h:nextg:pokev+21,2+4:pokev+40,7
|
By using pokes into screen memory it can be even smaller/faster:
| Code: |
0v=53248:z=56320:c=z+1:f=255:q=v+2:w=v+3:e=v+4:r=v+5:y=100:i=180:m=4
1a=49:s=234:d=13:b=1:printchr$(147):forn=1056to2016step40:poken,116:next
2o=2:l=4:n=8:poke2041,13
4poke2042,13:forg=0to62:readh:poke832+g,h:nextg:pokev+21,2+4:pokev+40,7 |
|
|
| Back to top |
|
 |
Forum Junkie

Joined: 15 Feb 2003 Posts: 530 Location: Manitoba, Canada
|
Posted: Fri Jun 22, 2012 3:17 pm Post subject: |
|
|
Not a request, a placeholder to challenge myself!! _________________ Proud Canuck and user of C64 systems since 1985. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Tip: Get C64 Forever for super-comfy C64 emulation with pre-installed games, demos and other goodies!
Powered by phpBB © 2001, 2005 phpBB Group
|