Main Menu

Recent posts

#81
Game Swap / VxTron32 release 1.0
Last post by jaymzjulian - June 17, 2020, 07:59:15 PM
So one near complete rewrite later, here's VxTron32 - as 3d tron game for the vectrex 32.  For the most part, it contains what it says on the tin - it's the tron light cycles game, for one or two players.  It also contains ducks.

https://www.youtube.com/watch?v=K1_07VBNwOY
another: https://www.youtube.com/watch?v=T2bl8Syi6VA

Controls for one player (third person):

joystick - move camera
button 1 - turn left
button 2 - turn right
button 3 - zoom camera in
button 4 - zoom camera out

Controls for one player (first person):

button 1 - turn left
button 2 - turn right
button 3 - peek left
button 4 - peek right

Controls for two players on one controller:

button 1 - turn left
button 2 - turn right
button 3 - turn left (player 2)
button 4 - turn right (player 2)

Un-combined source is at https://github.com/jaymzjulian/vltron

ProTip: Generally I watch the map more than the 3d display when trying to judge distance, because there is still an amount of vector drift.  You can totally play it in pure 3d, and sometimes I do, but it helped me, at least!  That applies less in first person mode....

There is theoretical support for two players on two controllers, however since I don't own two controllers, who knows if it works.  I'll put out a patch release if it does not....

Note: You need to copy all of the files in the zip to your vectrex32 for this to run (except the README.md, it doesn't read that ;)) since, in order to conserve memory, certain items are streamed from the storage.

(My next game will definitely not take six months ;))
#82
News and Updates / Firmware upgrade: 1.24
Last post by Vectrex32 - June 15, 2020, 09:11:14 AM
There's a new version of the Vectrex32 firmware available, version 1.24. You can download the firmware here.

There are new features and bug fixes. See the release notes here.

- Bob
#83
Code Swap / Re: Object Explosion Generator
Last post by jaymzjulian - May 29, 2020, 08:34:56 PM
Quote from: Vectrex32 on May 29, 2020, 08:44:03 AM
If you look up "Parkinson's Law of Data", there's a picture of you. ;-)

I'm basically a toddler - if there's a limit, i can't resist pushing at it to see where it breaks!
#84
Code Swap / Re: Object Explosion Generator
Last post by Vectrex32 - May 29, 2020, 08:44:03 AM
If you look up "Parkinson's Law of Data", there's a picture of you. ;-)
#85
Code Swap / Save memory by reading complex...
Last post by jaymzjulian - May 29, 2020, 05:09:07 AM
So I keep running out of memory (this is what i get for starting to have animations, right ;)), which kind of sucks, but then it occurred to me that having a second copy of the data for my sprites in memory was kind of a problem..... and indeed, this got me back to being able to boot into the game, so I though i'd share it:


function reado32(filename)
  file = fopen(filename, "rt")
  dimensions = Int(Val(fgets(file)))
  command_count = Int(Val(fgets(file)))
  print "Reading "+command_count+"commands of "+dimensions+"d object from "+filename
  dim o[command_count, dimensions + 1]
  for j = 1 to command_count
    o[j, 1] = Int(Val(fgets(file)))
    for k = 1 to dimensions
      o[j, k+1] = Val(fgets(file))
    next
  next
  print "done!"
  return o
endfunction



The format is:
[dimensions]
[commands]
... and then [commands] list of comamnds.  I formed my test file by taking a function, and doing:

cat lightcycle.bai | sed 's/MoveTo/0/g' | sed 's/DrawTo/1/g' | sed 's/,/\r/g' | sed 's/\{/\r/g' | sed 's/}/\r/g' | sed 's/_/\r/g' | sed '/^ *$/d' > lightcycle.o32
and then filling in my dimensions(3) and vertex count (145) at the top of the file, resulting in:


3
145
0
-0.284963
-0.242065
1.085209
1
-0.284963
-0.550938
1.394082
1
-0.452639
-0.242065
1.394082
1
-0.284963
-0.242065
1.702956
#86
Code Swap / Re: Object Explosion Generator
Last post by jaymzjulian - May 29, 2020, 04:33:07 AM
Back doing vectrex stuff again, finally - when i went to integrate this into a game, i found that it could cause frame rate drops if you had complex objects (specifically, the 220 vertex cycles in vxtron) - if i exploded 1, it was fine, if i exploded 2 at once, the framerate started dropping way back.  So I added a cached mode for the ram tradeoff.


' grab 2 seconds worth of explosion - 40frams @ 20 fps                                                                  ' Note that generating more than about 10k verticies _will_ break things - for this demo, our object is
' 220 broken vertificies - this means it tkaes 220*30*4 array entries for this, or 26400 array entries for
' this precalc - so on large objects, essentially be careful!  Especially since you need to multiply that also
' out due to them being 4byte floats/ints - so after 52 frames, the v32 runs out of ram in the generation phase.
' I suspect that's also some not-so-great GC, since we use a bunch of deepcopy stuff in there, BUT... still,
' that's 183kbytes of data at that point, which DOES match with my expectations about what the v32 can handle!
'
' So the short version is, be careful about your frame rates ;)
call fill_cache(ce, 40, 20)


Then in your loop

' grab explosion based off timer
new_data = cached_explosion(ce)
' and display it!
Lines2dSprite(new_data)



It's in the vectrex32_tools github @ https://github.com/jaymzjulian/vectrex32_tools.
#87
Code Swap / Re: Easing Demo
Last post by jaymzjulian - May 08, 2020, 04:35:24 PM
Oh hey, cool - i hadn't seen that site before, either, quite useful :)
#88
Code Swap / Easing Demo
Last post by VectorWorlds - May 04, 2020, 06:55:30 PM
I wanted to use some easing functions in my new game and converted some code from https://easings.net/#

I have included a small demo to show the easing effects of each function.  These functions can be handy for transitioning an object to another position, or transitioning from one scale to another for in a non linear way.

Call SetFrameRate(90)

currentEaseType = 1
easeNames={"ease In Sine","ease Out Sine","ease In Out Sine","ease In Quad","ease Out Quad","ease In Out Quad","ease In Cubic",_
"ease Out Cubic","ease In Out Cubic","ease In Quart","ease Out Quart","ease In Out Quart","ease In Quint","ease Out Quint",_
"ease In Out Quint","ease In Expo","ease Out Expo","ease In Out Expo","ease In Circ","ease Out Circ","ease In Out Circ",_
"ease In Back","ease Out Back","ease In Out Back","ease In Elastic","ease Out Elastic","ease In Out Elastic",_
"ease In Bounce","ease Out Bounce","ease In Out Bounce"}

call ReturnToOriginSprite()
call MoveSprite(-17,60)
title = textSprite("EASING DEMO")

call ReturnToOriginSprite()
call MoveSprite(-110,-90)
call textSprite("LEFT AND RIGHT TO CHANGE EASE TYPE")
call ReturnToOriginSprite()
call MoveSprite(-80,-105)
call textSprite("BUTTON 1 TO RESET ANIMATION")

easeRet =  ReturnToOriginSprite()
easeTextPos =  MoveSprite(0,-130)
easeText = textSprite(ToUpper(easeNames[currentEaseType]))

call RefreshEaseNameText()

buttonWait = 0 'delay for button presses
buttonWaitAmount = 5 'how long to wait between button presses

yoffset = 40
plotRet = 0
plotSprite = ReturnToOriginSprite()
dim points[0,3]
plotRet = ReturnToOriginSprite()
call plotEase()

call ReturnToOriginSprite()
octagon = RegularPolygon(8, 3, 180.0 / 8)
octaSprite = LinesSprite(octagon)
call SpriteTranslate(octaSprite,{-50,0})

octaPos = 0

while 1 do
controls = WaitForFrame(JoystickDigital, Controller1 + Controller2, JoystickX + JoystickY)
stickx = controls[1,1]

if stickx<-20 then 'Left
if buttonWait = 0 then
call PrevEaseType()
endif
buttonWait = buttonWaitAmount
endif

if stickx>20  then 'Right
if buttonWait = 0 then
call NextEaseType()
endif
buttonWait = buttonWaitAmount
endif

if controls[1,3] > 0 then
octaPos = 0
endif

if buttonWait > 0 then
buttonWait = buttonWait - 1
endif

call UpdateOcta()

endwhile

sub UpdateOcta()
scale = 60
if octaPos < 1 then
octaPos = octaPos + 0.0085
if octaPos > 1 then
octaPos = 1
endif
call SpriteTranslate(octaSprite,{-50,(-getEase(currentEaseType,octaPos) * scale) + yoffset})
endif
endsub

sub PlotEase()
scale = 3
x = 0
y = 0 + yoffset
points = nil
dim points[0,3]
if not IsNil plotSprite then
call removeSprite(plotSprite)
endif
newline = {{moveto,x,y}}
points = AppendArrays(points,newline)
for i = 0 to 1 step 0.04
y = (-getEase(currentEaseType,i) * 60) + yoffset
newline = {{drawto,x,y}}
points = AppendArrays(points,newline)
x = x + scale
next
plotSprite = linesSprite(points)
call PutSpriteAfter(plotRet,plotSprite)
endSub

function getEase(index,amt)
if index = 1 then
return easeInSine(amt)
endif
if index = 2 then
return easeOutSine(amt)
endif
if index = 3 then
return easeInOutSine(amt)
endif
if index = 4 then
return easeInQuad(amt)
endif
if index = 5 then
return easeOutQuad(amt)
endif
if index = 6 then
return easeInOutQuad(amt)
endif
if index = 7 then
return easeInCubic(amt)
endif
if index = 8 then
return easeOutCubic(amt)
endif
if index = 9 then
return easeInOutCubic(amt)
endif
if index = 10 then
return easeInQuart(amt)
endif
if index = 11 then
return easeOutQuart(amt)
endif
if index = 12 then
return easeInOutQuart(amt)
endif
if index = 13 then
return easeInQuint(amt)
endif
if index = 14 then
return easeOutQuint(amt)
endif
if index = 15 then
return easeInOutQuint(amt)
endif
if index = 16 then
return easeInExpo(amt)
endif
if index = 17 then
return easeOutExpo(amt)
endif
if index = 18 then
return easeInOutExpo(amt)
endif
if index = 19 then
return easeInCirc(amt)
endif
if index = 20 then
return easeOutCirc(amt)
endif
if index = 21 then
return easeInOutCirc(amt)
endif
if index = 22 then
return easeInBack(amt)
endif
if index = 23 then
return easeOutBack(amt)
endif
if index = 24 then
return easeInOutBack(amt)
endif
if index = 25 then
return easeInElastic(amt)
endif
if index = 26 then
return easeOutElastic(amt)
endif
if index = 27 then
return easeInOutElastic(amt)
endif
if index = 28 then
return easeInBounce(amt)
endif
if index = 29 then
return easeOutBounce(amt)
endif
if index = 30 then
return easeInOutBounce(amt)
endif
endFunction

sub NextEaseType()
currentEaseType = currentEaseType + 1
if currentEaseType > ubound(easeNames) then
currentEaseType = 1
endif
octaPos = 0
call RefreshEaseNameText()
call PlotEase()
endSub

sub PrevEaseType()
currentEaseType = currentEaseType - 1
if currentEaseType = 0 then
currentEaseType = ubound(easeNames)
endif
octaPos = 0
call RefreshEaseNameText()
call PlotEase()
endSub

sub RefreshEaseNameText()
call RemoveSprite(easeText)
easeText = textSprite(ToUpper(easeNames[currentEaseType]))
call PutSpriteAfter(easeTextPos,easeText)

call RemoveSprite(easeTextPos)
easeTextPos = MoveSprite(-Len(easeNames[currentEaseType])*3,100)
call PutSpriteBefore(easeText,easeTextPos)
endSub

'// TWEENING FUNCTIONS
'// https://easings.net/

function easeInSine(n)
  return 1 - cos((n * PI) / 2)
endFunction

function easeOutSine(n)
  return sin((n * PI) / 2)
endFunction

function easeInOutSine(n)
return -(cos(PI * n) - 1) / 2
endFunction

function easeInQuad(n)
return n * n
endFunction

function easeOutQuad(n)
return 1 - (1 - n) * (1 - n)
endFunction

function easeInOutQuad(n)
if n < 0.5 then
return 2 * n * n
else
return 1 - pow(-2 * n + 2, 2) / 2
endif
endfunction

function easeInCubic(n)
return n * n * n
EndFunction

function easeOutCubic(n)
return 1 - pow(1 - n, 3)
endFunction

function easeInOutCubic(n)
if n < 0.5 then
return 4 * n * n * n
else
return 1 - pow(-2 * n + 2, 3) / 2
endif
endFunction

function easeInQuart(n)
return n * n * n * n
endFunction

function easeOutQuart(n)
return 1 - pow(1 - n, 4)
endFunction

function easeInOutQuart(n)
if n < 0.5 then
return 8 * n * n * n * n
else
return 1 - pow(-2 * n + 2, 4) / 2
endif
endFunction

function easeInQuint(n)
return n * n * n * n * n
endFunction

function easeOutQuint(n)
return 1 - pow(1 - n, 5)
endFunction

function easeInOutQuint(n)
if n < 0.5 then
return 16 * n * n * n * n * n
else
return 1 - pow(-2 * n + 2, 5) / 2
endif
endFunction

function easeInExpo(n)
if n = 0 then
return 0
else
return pow(2, 10 * n - 10)
endif
endFunction

function easeOutExpo(n)
if n = 1 then
return 1
else
return 1 - pow(2, -10 * n)
endif
endFunction

function easeInOutExpo(n)
if n = 0 then
return 0
else
if n = 1 then
return 1
else
if n < 0.5 then
return pow(2, 20 * n - 10) / 2
else
return (2 - pow(2, -20 * n + 10)) / 2
endif
endif
endif
endFunction

function easeInCirc(n)
return 1 - sqrt(1 - pow(n, 2))
endfunction

function easeOutCirc(n)
return sqrt(1 - pow(n - 1, 2))
endFunction

function easeInOutCirc(n)
if n < 0.5 then
return (1 - sqrt(1 - pow(2 * n, 2))) / 2
else
return (sqrt(1 - pow(-2 * n + 2, 2)) + 1) / 2
endif
endFunction

function easeInBack(n)
c1 = 1.70158
c3 = c1 + 1

return c3 * n * n * n - c1 * n * n
endFunction

function easeOutBack(n)
c1 = 1.70158
c3 = c1 + 1
return 1 + c3 * pow(n - 1, 3) + c1 * pow(n - 1, 2)
endFunction

function easeInOutBack(n)
c1 = 1.70158
c2 = c1 * 1.525

if n < 0.5 then
return (pow(2 * n, 2) * ((c2 + 1) * 2 * n - c2)) / 2
else
return (pow(2 * n - 2, 2) * ((c2 + 1) * (n * 2 - 2) + c2) + 2) / 2
endif
endFunction

function easeInElastic(n)
c4 = (2 * PI) / 3
if n = 0 then
return 0
else
if n = 1 then
return 1
else
return -pow(2, 10 * n - 10) * Sin((n * 10 - 10.75) * c4)
endif
endif
endFunction

function easeOutElastic(n)
c4 = (2 * PI) / 3
if n = 0 then
return 0
else
if n = 1 then
return 1
else
return pow(2, -10 * n) * Sin((n * 10 - 0.75) * c4) + 1
endif
endif
endFunction

function easeInOutElastic(n)
c5 = (2 * PI) / 4.5
if n = 0 then
return 0
else
if n = 1 then
return 1
else
if n < 0.5 then
return -(pow(2, 20 * n - 10) * Sin((20 * n - 11.125) * c5)) / 2
else
return (pow(2, -20 * n + 10) * Sin((20 * n - 11.125) * c5)) / 2 + 1
endif
endif
endif
endFunction

function easeInBounce(n)
return 1 - easeOutBounce(1 - n)
endFunction

function easeOutBounce(n)
n1 = 7.5625
d1 = 2.75

if (n < 1 / d1) then
return n1 * n * n
else
if (n < 2 / d1) then
n = n - (1.5 / d1)
return n1 * n * n + 0.75
'return n1 * (n -= 1.5 / d1) * n + 0.75
else
if (n < 2.5 / d1) then
n = n - (2.25 / d1)
return n1 * n * n + 0.9375
'return n1 * (n -= 2.25 / d1) * n + 0.9375
else
n = n - (2.625 / d1)
return n1 * n * n + 0.984375
'return n1 * (n -= 2.625 / d1) * n + 0.984375
endif
endif
endif
endFunction

function easeInOutBounce(n)
if n < 0.5 then
return (1 - easeOutBounce(1 - 2 * n)) / 2
else
return (1 + easeOutBounce(2 * n - 1)) / 2
endif
endFunction


Cheers,


Andrew
#89
General Discussion / Re: Vectrex32 and Max MSP
Last post by jaymzjulian - April 11, 2020, 08:26:08 PM
Another sample: https://github.com/jaymzjulian/vectrex32_vstemu - this implements the v.st vector generator protocol over serialusb.  I can run the processing demos with it, but i'm still trying to build vectormame.  I'll post a video if i ever manage to make that part work..... dunno if the serial will be usefully fast enough, but i guess we'll see!

I'm using https://github.com/geoffmeyers/interceptty to watch the serial instead now - so i load in my terminal, disconnect that, then run ./interceptty -e 13 -l -f char /dev/ttyS3 to see any output the v32 gives me when I messed up my code (I always messed up my code ;))

#90
General Discussion / Re: Vectrex32 and Max MSP
Last post by jaymzjulian - April 09, 2020, 01:06:32 AM
One more piece of advice on this - I'l actually doing some experimenting with serial today (implmenting a v.st vector protocol parser, so i can play star wars ;)), and I found of course, that two people not being able to be on the serial at once was a problem.  particularly, you can't debug ;).

I did find a tool around this though, which is i installed a driver that lets me share a serial port between two applications - https://www.eltima.com/article/share-com-port-between-apps/ .  others might have a better solution though!