Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:55 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 2 of 7    
Author Message
vegipete

Guru

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

Now there actually are some PicoRocks to dodge. Well, actually, no dodging required because they can't hurt you.

Four different rocks are defined, and they can be drawn at different sizes. At this stage, drawing speed looks fine.

Collision detection is where the grunt work happens though. For my CMM2 Rocks-in-Space, the distance from each ship to each rock, and from each shot to each target is tested every iteration. The new imaginary number features might be useful to calculate this distance.

Keyboard control (via console) is not great, certainly nowhere as responsive as on the CMM2.
Visit Vegipete's *Mite Library for cool programs.
 
stanleyella

Guru

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

It's all top of my head ideas for haemorrhoids (pain in the arse to program).
wrap around is my prob, since collapsing to edge on overflow off screen.
 
stanleyella

Guru

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

got wraparound sort of working
this is just to see line drawn rocks and speed and looking promising



rock1
rx1=rx1-4:ry1=ry1+4
if rx1<-16 then rx1=640
if rx1>640 then rx1=-16
if ry1>480 then ry1=-16
if ry1<-16 then ry1=480

rock2
rx2=rx2+4:ry2=ry2-8
if rx2<-16 then rx2=640
if rx2>640 then rx2=-16
if ry2>480 then ry2=-16
if ry2<-16 then ry2=480

rock3
rx3=rx3+8:ry3=ry3-4
if rx3<-16 then rx3=640
if rx3>640 then rx3=-16
if ry3>480 then ry3=-16
if ry3<-16 then ry3=480

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 rock3
line rx2+12,ry2,rx2+28,ry2+12
line rx2+28,ry2+12,rx2+44,ry2
line rx2+44,ry2,rx2+60,ry2+12
line rx2+60,ry2+12,rx2+44,ry2+28
line rx2+44,ry2+28,rx2+60,ry2+44
line rx2+60,ry2+44,rx2+36,ry2+60
line rx2+36,ry2+60,rx2+16,ry2+60
line rx2+16,ry2+60,rx2,ry2+44
line rx2,ry2+44,rx2,ry2+16
line rx2,ry2+16,rx2+12,ry2
end sub

sub rock2
line rx3+9,ry3,rx3+21,ry3+9
line rx3+21,ry3+9,rx3+33,ry3
line rx3+33,ry3,rx3+40,ry3+9
line rx3+40,ry3+9,rx3+33,ry3+21
line rx3+33,ry3+21,rx3+40,ry3+33
line rx3+40,ry3+33,rx3+24,ry3+40
line rx3+24,ry3+40,rx3+12,ry3+40
line rx3+12,ry3+40,rx3,ry3+36
line rx3,ry3+36,rx3,ry3+12
line rx3,ry3+12,rx3+9,ry3
end sub



 
stanleyella

Guru

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

you get a compressed image to line if you go off bottom or left scree but co-ords still valid.
and if x or y <0 they work as -16. weird but cool.
I think pico asteroids doable

 
stanleyella

Guru

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

rocks01 looks nice. I commented autorun cos error unknown command
you got the same line problem when off left or top screen
 DrawRocks
box 0,0,320,240,,rgb(black)
 FRAMEBUFFER copy F,N,B
loop
sorts it. stan
 
stanleyella

Guru

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

imho 16 ship rotations and draw it.not all that data.
makes thrust different but missiles only 16 directions.
original arcade game seemed simpler.
collision checking is 4 checks per shape,.. maybe test pixels.
nice job your doing, lots of new commands I've not learnt yet.
 
vegipete

Guru

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

Update to PicoRocks, using the new array rotate command added to firmware v5.08.00RC4

The program is suddenly a whole lot shorter.

For fun, I've made all the rocks rotate too. This will really bog down though if many many rocks need to be drawn.

Edit: The program below works fine in MODE 1 too, just change line 12. No colours, of course. You might also want to scale things up a bit.
'=============================================================================|
' PicoRocks in Space - Teaser
'
' written by Vegipete, Jan 2024
' Ported from CMM2 (somewhat)
'
' needs:
' OPTION CPUSPEED 252000 (KHz)

Option DEFAULT INTEGER
Option LCDPANEL NOCONSOLE
option angle degrees
MODE 2
cls 0

const MAXROCKS = 50
dim float rock(MAXROCKS,7) ' 50 rocks: scale,angle,x,y,vx,vy,a,da
dim trock (MAXROCKS)  ' type of rock
math set 0, rock()  ' erase them all to start
math set 0,trock()

' rock vector shapes
' Note: any resemblance to a country is purely coincidental
dim r1x(14)=( 0, 3, 4, 3, 5, 4, 1,-2,-4,-5,-3,-5,-3,-2, 0)
dim r1y(14)=( 5, 4, 3, 1, 0,-4,-5,-4,-4,-1,-1, 2, 3, 5, 5)
dim r2x(14)=( 0,-2,-3,-4,-5,-4,-4,-3,-1, 4, 4, 5, 4, 2, 0)
dim r2y(14)=(-6,-4,-3,-4,-1, 2, 3, 3, 5, 3, 1, 0,-3,-4,-6)
dim r3x(14)=( 1,-2,-2,-4,-4,-5,-5,-3,-2, 0, 4, 3, 5, 3, 1)
dim r3y(14)=(-4,-5,-3,-4,-2, 0, 3, 4, 3, 5, 3, 2, 1,-5,-4)
dim r4x(14)=( 0,-2,-4,-4,-5,-3,-1, 2, 1, 3, 5, 3, 4, 3, 0)
dim r4y(14)=(-5,-4,-4,-1, 1, 4, 5, 5, 3, 4, 1,-2,-3,-4,-5)

' player ship and exhaust flame shapes
dim shpx(4)=(0,-3,0,3,0)
dim shpy(4)=(-5,5,3,5,-5)
dim flmx(4)=(0,-1,0,1,0)
dim flmy(4)=(4,5,7,5,4)

FRAMEBUFFER Create   ' hidden layer to draw scene
FRAMEBUFFER Write F : CLS 0

dim float pv,px,py,pvx,pvy

ph = 0 : pv = 0
px = MM.HRES/2-6 : pvx = 0
py = MM.VRES/2-6 : pvy = 0

' create some random rocks
k = 1
for i = 1 to 10
 trock(i)  = 1 + (k and 3) ' rock type (0=doesn't exist)
 rock(i,0) = 1+int(rnd*3)  ' rock size
 rock(i,2) = rnd*MM.HRES   ' x location
 rock(i,3) = rnd*MM.VRES   ' y location
 rock(i,4) = 1-rnd*2   ' x velocity
 rock(i,5) = 1-rnd*2   ' y velocity
 rock(i,6) = rnd*360   ' starting angle
 rock(i,7) = 3-rnd*6   ' rotation speed
 inc k
next

mot = timer

do
 k = asc(inkey$)
 if k then
   burn = 0
   select case k
     Case 128  ' up
       inc pvx, sin(ph)/2
       inc pvy,-cos(ph)/2
       mot = timer + 100   ' keep flame visible for a while
     Case 130  ' left
       inc ph,-5
       if ph < 0 then ph = 355
     Case 131  ' right
       inc ph,5
       if ph > 355 then ph = 0
   end select
 endif
 
 inc px,pvx
 if px > MM.HRES then
   inc px, -(MM.HRES+6)
 elseif px < 5 then
   inc px, MM.HRES+6
 endif
 
 inc py,pvy
 if py > MM.VRES then
   inc py, -(MM.VRES+6)
 elseif py < 0 then
   inc py, MM.VRES+6
 endif
 
 ' velocity decays away slowly
 pvx = pvx * .995
 pvy = pvy * .995

 ' move rocks
 for i = 0 to MAXROCKS
   if trock(i) then   ' rock exists
     inc rock(i,2),rock(i,4)
     if rock(i,2) > MM.HRES then
       inc rock(i,2), -MM.HRES
     elseif rock(i,2) < 0 then
       inc rock(i,2), MM.HRES
     endif
     
     inc rock(i,3),rock(i,5)
     if rock(i,3) > MM.VRES then
       inc rock(i,3), -MM.VRES
     elseif rock(i,3) < 0 then
       inc rock(i,3), MM.VRES
     endif
   endif
 next
 
 cls
 DrawShip
 DrawRocks
 FRAMEBUFFER copy F,N,B
loop

sub DrawShip
 local x(4),y(4)
 'off = (mot > timer) * 6624
 'Sprite memory SPRADDR+off+ph*92,px,py
 math scale shpx(),1,x()
 math scale shpy(),1,y()
 math v_rotate 0,0,ph,x(),y(),x(),y()
 math add x(),px,x()  ' position ship
 math add y(),py,y()
 polygon 5,x(),y(),rgb(green)
 if mot > timer then
   math scale flmx(),1,x()
   math scale flmy(),1,y()
   math v_rotate 0,0,ph,x(),y(),x(),y()
   math add x(),px,x()  ' position rocket flame
   math add y(),py,y()
   polygon 5,x(),y(),rgb(brown)
 endif
end sub

' Go through the list of rocks and draw any that exist
sub DrawRocks
 local i
 local x(14),y(14)
 
 for i = 0 to MAXROCKS
   if trock(i) then   ' rock exists
     inc rock(i,6),rock(i,7) ' spin rock
     if rock(i,6) > 360 then inc rock(i,6),-360
     if rock(i,6) < 0 then inc rock(i,6),360

     select case trock(i) ' what shape of rock is it?
       case 1
         math scale r1x(),rock(i,0),x()
         math scale r1y(),rock(i,0),y()
       case 2
         math scale r2x(),rock(i,0),x()
         math scale r2y(),rock(i,0),y()
       case 3
         math scale r3x(),rock(i,0),x()
         math scale r3y(),rock(i,0),y()
       case 4
         math scale r4x(),rock(i,0),x()
         math scale r4y(),rock(i,0),y()
     end select
     math v_rotate 0,0,rock(i,6),x(),y(),x(),y()
     math add x(),rock(i,2),x()  ' position rock
     math add y(),rock(i,3),y()
     polygon 15,x(),y()
   endif
 next i
end sub


Edited 2024-01-19 11:34 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1113
Posted: 09:32am 19 Jan 2024
Copy link to clipboard 
Print this post

Nice  
(I prefer Mode 1)
Edited 2024-01-19 20:12 by Martin H.
'no comment
 
stanleyella

Guru

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

I get syntax error in sub DrawShip
RUN
[134] Math v_rotate 0,0,ph,x(),y(),x(),y()
Error : Syntax
> option list
PicoMiteVGA MMBasic Version 5.08.00b5
 
lizby
Guru

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

  stanleyella said  ... PicoMiteVGA MMBasic Version 5.08.00b5


You identified your problem--several versions behind the times.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
stanleyella

Guru

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

  lizby said  
  stanleyella said  ... PicoMiteVGA MMBasic Version 5.08.00b5


You identified your problem--several versions behind the times.

I can't get V5.08.00RC4  https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip
it's just a text file saying At this time no new Beta version is available
I got rc3
Edited 2024-01-20 03:28 by stanleyella
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6779
Posted: 05:14pm 19 Jan 2024
Copy link to clipboard 
Print this post

Get the latest version from Geoff's site, Stan. It's got the new manual and everything.
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:35pm 19 Jan 2024
Copy link to clipboard 
Print this post

No Mick RC04 from beta download is just a text file.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4036
Posted: 06:16pm 19 Jan 2024
Copy link to clipboard 
Print this post

  stanleyella said  No Mick RC04 from beta download is just a text file.


Stanley the beta and release-candidate periods are over and there has been an official release, see the links in this thread https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=16607

Best wishes,

Tom
Edited 2024-01-20 04:17 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
stanleyella

Guru

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

Thank you Tom, I saw the thread before but didn't connect.
code works now with picomite vga5.08.00 and it's very impressive! loads to learn from, much better than my methods. nice to see someone who knows his stuff sharing mmb features with example code.
my 5 pence, less points on rocks
don't rotate rocks-looks cool like asteroids deluxe
test pixel not black around ship=collision... missiles more testing :)
DrawShip
DrawRocks
if pixel (px-8,py-8)>0 or pixel (px+8,py-8)>0 or pixel (px-8,py+8)>0 or pixel (px+8,py+8)>0 then circle px,py,8

FRAMEBUFFER copy F,N,B
loop

if pixel (px-8,py-8)=0 then if pixel (px+8,py-8)=0 then if pixel (px-8,py+8)=0 then if pixel (px+8,py+8)=0 then skip else collision.
bit faster
cls
if pixel (px-8,py-8)=0 then if pixel (px+8,py-8)=0 then if pixel (px-8,py+8)=0 then if pixel (px+8,py+8)=0 then DrawShip
else circle px,py,8 'ship blows
endif
DrawRocks
FRAMEBUFFER copy F,N,B
loop
Edited 2024-01-21 03:26 by stanleyella
 
stanleyella

Guru

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

if missilex>rockx then if missilex<(rockx+rockwid)
then if missiley>rocky then if missiley<(rocky+rockheight)
then rock hit
 
stanleyella

Guru

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

rotate ship +-10 is nicer.
don't rotate rocks is much faster.
as is, imho mode 1 is better.
Edited 2024-01-21 08:13 by stanleyella
 
stanleyella

Guru

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

strange with ili and non vga
https://www.youtube.com/watch?v=RWVrMc5veOY
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4223
Posted: 07:04am 23 Jul 2024
Copy link to clipboard 
Print this post

Pete, Stanley,

Anyone object if I take this a bit further ? There have not been updates for some time, but in the background you could have been working on it.
I am aiming at 640x480 to closer mimick the original monochrome vector graphics.



Volhout
PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1113
Posted: 09:43am 23 Jul 2024
Copy link to clipboard 
Print this post

  Volhout said  Pete, Stanley,

Anyone object if I take this a bit further ? There have not been updates for some time, but in the background you could have been working on it.
I am aiming at 640x480 to closer mimick the original monochrome vector graphics.



Volhout

Harm,

looks even better if you place a Tile 0,0,RGB(green),0,80,40 after the CLS in Line 121

Cheers
Martin
Edited 2024-07-23 19:43 by Martin H.
'no comment
 
     Page 2 of 7    
Print this page
© JAQ Software 2024