Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:27 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoRocks - A Teaser

     Page 1 of 7    
Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 04:08am 09 Jan 2024
Copy link to clipboard 
Print this post

To test some things, I bashed this together for the PicoMiteVGA. It shows some potential.
(Delete the first 2 lines if you are not transferring via AUTOSAVE.)

I am puzzled by something, though. When you pilot the ship slowly off the top or left edges, the intensity drops. It appears normal everywhere else. Hmmm. (It might be related to framebuffer copying. If you hit ctrl-C while the ship is in the dim zone, it goes back to full intensity.)
(PicoMiteVGA MMBasic Version 5.07.08RC21)
Edited 2024-01-09 14:15 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 02:41pm 09 Jan 2024
Copy link to clipboard 
Print this post

Hi Vegipete,

I see no "rocks" yet...only the spaceship.
But when I accelerate it gets warp speed 10.... Wauw.

You are busy with a zillion projects at the same time. Need any help to finish one of them ? LR, RIS, Qbert ... ?

Volhout

P.S. I wonder if the "vector graphics" resolution of the arcade game could be implemented in mode 1 (640x480) using a "tile" to color the plane if you like. But the original game was B/W only.
Edited 2024-01-10 01:16 by Volhout
PicomiteVGA PETSCII ROBOTS
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 05:26pm 09 Jan 2024
Copy link to clipboard 
Print this post

I looked at the code cos asteroids was a favourite and not tried but looks interesting.
I was thinking of polygons not sprites and no trig.
the original arcade used phosphor fade and the rocks were drawn not erased
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 06:57pm 09 Jan 2024
Copy link to clipboard 
Print this post

As I said, this was to test some things. The little demo uses 144 sprites. I wasn't about to draw them by hand. Instead, the ship was defined by 4 points, rotated to each angle and drawn. The images were then read and converted to CSub data.

Stan has pointed out something else to test - how long does it take to draw the ship as a polygon instead of as a CSub sprite, and can rotation be calculated on the fly or must it be precalculated?

Do CSub sprites work in mode 1 (640x480)? I haven't tried...
Visit Vegipete's *Mite Library for cool programs.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 07:04pm 09 Jan 2024
Copy link to clipboard 
Print this post

tried the code and got rotating ship and thrust. nice.
I'll try polygons and frames for fps, see fastest way. stan
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 12:04am 10 Jan 2024
Copy link to clipboard 
Print this post

Polygons need all the elements in the x,y arrays changed to move them.
using joined lines relative to x,y may be faster. testing
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 06:32pm 10 Jan 2024
Copy link to clipboard 
Print this post

rotating ship?

xcentre=63
ycentre=58
radius=8
do

for d=0 to 359 step 10
cls

xp = xcentre + radius  * sin (rad(d))
yp = ycentre - radius  * cos (rad(d))
e=d+140:if e>359 then e=e-359
f=d+220:if f>359 then f=f-359
xe1 = xcentre + radius  * sin (rad(e))
ye1 = ycentre - radius  * cos (rad(e))
xe2 = xcentre + radius  * sin (rad(f))
ye2 = ycentre - radius  * cos (rad(f))

line xe1,ye1,xp,yp,,1
line xp,yp,xe2,ye2,,1

pause 50
next d
loop

 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 06:57pm 10 Jan 2024
Copy link to clipboard 
Print this post

The firing shots at different degrees will be fun to implement.
the rotating ship seems low memory and drawing the rocks could be fast enough. use frames no erase . a smaller display area to get wrap around and frames.
I'll try to chip in for the picomite asteroids if I can help. stan
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 08:11pm 10 Jan 2024
Copy link to clipboard 
Print this post

bit more efficient rotating ship

xcentre=63
ycentre=58
radius=8
do

for d=0 to 359 step 10
cls
rd=rad(d)
xp = xcentre + radius  * sin (rd)
yp = ycentre - radius  * cos (rd)

e=d+140:if e>359 then e=e-359
rd=rad(e)
xe1 = xcentre + radius  * sin (rd)
ye1 = ycentre - radius  * cos (rd)

e=d+220:if e>359 then e=e-359
rd=rad(e)
xe2 = xcentre + radius  * sin (rd)
ye2 = ycentre - radius  * cos (rd)

line xe1,ye1,xp,yp,,1
line xp,yp,xe2,ye2,,1

pause 50
next d
loop


Footnote added 2024-01-11 07:32 by stanleyella
add
line xe2,ye2,xcentre,ycentre,,1
line xcentre,ycentre,xe1,ye1,,1
for a proper ship :)
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 08:31pm 10 Jan 2024
Copy link to clipboard 
Print this post

how many angles for the ship? 16 with no trig except the ship rotate, so many x,y pixels for missiles and ship forward.? stan
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 09:42pm 10 Jan 2024
Copy link to clipboard 
Print this post

Ship rotation thoughts:
I started with my Rocks in Space for the CMM2. It used 96 steps for the full rotation of a 32ish pixel square ship canvas on an 800x600 screen. Scaling that ship size to the PicoMite resolution gave me a 13 pixel square canvas - convenient because that results in an actual center point. Sketched a 4-point ship, put the coordinates into a little program, plotted it, fettled a bit, sorted. Then I started rotating the resulting ship to see what number of steps looked good. 96 was unnecessarily many, 72 was aesthetically pleasing.

Here's the code I used to generate the ships:
Option DEFAULT INTEGER
option angle degrees
MODE 2
cls 0

' ship data: 4 points for ship, 5 points for flame
dim float body(8,1):for i=0 to 8:read body(i,0):read body(i,1):next
data 0,-6,-3,4,0,2,3,4,0,4,0,5,-1,5,0,6,1,5

dim float rc(8,1)  ' work copy of ship
dim float sa,ca

mx = 6 : my = 56
for a = 0 to 359 step 5

 ' rotate a copy of the ship
 sa = sin(a) : ca = cos(a)  ' only do this once!
 for i = 0 to 8
   rc(i,0) = body(i,0) * ca - body(i,1) * sa
   rc(i,1) = body(i,0) * sa + body(i,1) * ca
 next

 ' ship body
 line mx+rc(0,0),my+rc(0,1),mx+rc(1,0),my+rc(1,1),,rgb(green)
 line mx+rc(1,0),my+rc(1,1),mx+rc(2,0),my+rc(2,1),,rgb(green)
 line mx+rc(2,0),my+rc(2,1),mx+rc(3,0),my+rc(3,1),,rgb(green)
 line mx+rc(3,0),my+rc(3,1),mx+rc(0,0),my+rc(0,1),,rgb(green)
 
 ' rocket flames
 pixel mx+rc(4,0),my+rc(4,1),rgb(yellow)
 pixel mx+rc(5,0),my+rc(5,1),rgb(brown)
 pixel mx+rc(6,0),my+rc(6,1),rgb(rust)
 pixel mx+rc(7,0),my+rc(7,1),rgb(rust)
 pixel mx+rc(8,0),my+rc(8,1),rgb(rust)
 
 ' advance to next image location
 mx = mx + 13
 if mx >= 239 then
   mx = 6
   my = my + 13
 endif
next a

Visit Vegipete's *Mite Library for cool programs.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 09:54pm 10 Jan 2024
Copy link to clipboard 
Print this post

radius=16 is nice

mode 1
xcentre=100
ycentre=100
radius=16
do
for d=0 to 359 step 16
cls
rd=rad(d)
xp = xcentre + radius  * sin (rd)'ship
yp = ycentre - radius  * cos (rd)'direction
'
e=d+140:if e>359 then e=e-359
rd=rad(e)
xe1 = xcentre + radius  * sin (rd)'ship
ye1 = ycentre - radius  * cos (rd)'tail left
'
e=d+220:if e>359 then e=e-359
rd=rad(e)
xe2 = xcentre + radius  * sin (rd)'ship
ye2 = ycentre - radius  * cos (rd)'tail right
'
line xe1,ye1,xp,yp,,1'           :
line xp,yp,xe2,ye2,,1'           :draw
line xe2,ye2,xcentre,ycentre,,1' :ship
line xcentre,ycentre,xe1,ye1,,1' :
pause 100
next d
loop

 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 10:19pm 10 Jan 2024
Copy link to clipboard 
Print this post

  vegipete said  Ship rotation thoughts:


In MMB4W:


PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 12:11am 11 Jan 2024
Copy link to clipboard 
Print this post

if drawn then 360 but how many in atari original game?
I was thinking of x,y centre to ship point ratio to get increments for movement and missile vector.
reminds me of startrek https://www.youtube.com/watch?v=CBj6AUrMVls
 
pwillard
Senior Member

Joined: 07/06/2022
Location: United States
Posts: 292
Posted: 12:28am 11 Jan 2024
Copy link to clipboard 
Print this post

The original atari game had one "shape" and used vector math to rotate... no sprites at all.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6779
Posted: 08:21am 11 Jan 2024
Copy link to clipboard 
Print this post

I'd suggest keeping the number of rotation steps as small as possible. The rotation won't actually be as smooth, but it will be faster - and you'll need CPU capacity to handle the drawing and movement of rocks. This is one of those cases where using a lookup table for the vertices of objects could be faster and easier than calculating them, but in order to keep the lookup table reasonable you have to keep the steps down.

Note that you can use just one or two lookup tables for rocks and simply scale them as needed.
Edited 2024-01-11 18:22 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 05:23pm 11 Jan 2024
Copy link to clipboard 
Print this post

For the classic atari asteroids look vga mode 1.
should it use sprites, line, or polygon?
I thought the sprite or blit on lcd had changed to not record black, dunno , which mmbasic version.
joined lines with 1 x,y start and the other points x,y with offset.
polygons, all points in the x,y arrays needing offset.
I got 16 16x16 sprites bouncing around very fast. a few rocks should be ok.
For the rock and ship and missile wrap around I thought copy a smaller frame than the drawing frame to the screen. just thoughts. stan
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 05:49pm 13 Jan 2024
Copy link to clipboard 
Print this post

I'm trying lines for rocksfrom x,y corner as sprite to move
change rx1,ry1 and draws rock there. sprite alternative?

sub rock1
line rx1+6,ry1,rx1+14,ry1+6
line rx1+14,ry1+6,rx1+22,ry1
line rx1+22,ry1,rx1+30,ry1+6
line rx1+30,ry1+6,rx1+22,ry1+14
line rx1+22,ry1+14,rx1+30,ry1+22
line rx1+30,ry1+22,rx1+18,ry1+30
line rx1+18,ry1+30,rx1+8,ry1+30
line rx1+8,ry1+30,rx1,ry1+26
line rx1,ry1+26,rx1,ry1+6
line rx1,ry1+6,rx1+6,ry1
end sub

sub rock2
line rx1+12,ry1,rx1+28,ry1+12
line rx1+28,ry1+12,rx1+44,ry1
line rx1+44,ry1,rx1+60,ry1+12
line rx1+60,ry1+12,rx1+44,ry1+28
line rx1+44,ry1+28,rx1+60,ry1+44
line rx1+60,ry1+44,rx1+36,ry1+60
line rx1+36,ry1+60,rx1+16,ry1+60
line rx1+16,ry1+60,rx1,ry1+44
line rx1,ry1+44,rx1,ry1+16
line rx1,ry1+16,rx1+12,ry1
end sub

sub rock3
line rx1+9,ry1,rx1+21,ry1+9
line rx1+21,ry1+9,rx1+33,ry1
line rx1+33,ry1,rx1+40,ry1+9
line rx1+40,ry1+9,rx1+33,ry1+21
line rx1+33,ry1+21,rx1+40,ry1+33
line rx1+40,ry1+33,rx1+24,ry1+40
line rx1+24,ry1+40,rx1+12,ry1+40
line rx1+12,ry1+40,rx1,ry1+36
line rx1,ry1+36,rx1,ry1+12
line rx1,ry1+12,rx1+9,ry1
end sub

 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 06:24pm 13 Jan 2024
Copy link to clipboard 
Print this post

  pwillard said  The original atari game had one "shape" and used vector math to rotate... no sprites at all.

A 6502 board with dacs connected to x,y b/w vector monitor.
if you turned the brightness control up you saw the the lines between the graphics as it drew a rock then moved to draw the next and all graphics.
In the original asteroids only the ship rotated.
I would make the saucer a sprite.. lot to draw.
Edited 2024-01-14 04:46 by stanleyella
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2120
Posted: 07:04pm 13 Jan 2024
Copy link to clipboard 
Print this post

  Mixtel90 said  
Note that you can use just one or two lookup tables for rocks and simply scale them as needed.

yes,thinking that.  please see rocks are multiples.
Edited 2024-01-14 05:20 by stanleyella
 
     Page 1 of 7    
Print this page
© JAQ Software 2024