Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - VectorWorlds

#1
Game Swap / Re: Star Trex
May 30, 2021, 07:21:18 AM
I found a more complete version knocking around on my hard-drive so thought I would upload here.

https://1drv.ms/u/s!ArslbYSzzvjwiLxMtgMK1fPmzP4HrQ?e=IWyxcN

Cheers,


Andrew
#2
Code Swap / Easing Demo
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
#3
Game Swap / Re: Star Trex
February 14, 2020, 07:56:55 PM
Hello All,

I've just uploaded a newer version.  I had restructure a some code the get a little more memory to play with.  I've have tidied up some loose ends and added some more effects like the map intro etc.

https://1drv.ms/u/s!ArslbYSzzvjwiKcjVrx6_XL3WSz4AQ?e=EUxhfO

I wasn't able to add the Klingon explosions yet, but I have some more ideas to somehow squeeze this in.

In the meantime thanks Bob for all the tips.  The game feels a little more polish now.

Cheers,


Andrew
#4
Game Swap / Star Trex
February 09, 2020, 11:48:49 AM
Hello,

Here's my first game on the Vectrex32 and my submission for the V Competition. I learnt a lot making this game and if I was to tackle it again I work on a more robust memory management.

In the end I bumped up against some of the constraints of the Vectrex32.  Some of these are likely caused by me not knowing enough yet on how to squeeze everything out of the system.  I did program hi-score tables, but I ran out of memory everytime I tried to implement them so I have left them out.  I also had trouble squeezing in more sounds but I will try and some more in future updates after I have refactored some more of the code.

I have also had to restrict the amount of ships on screen at any given time to keep within the 2K limit.  To still allow the game to be progressively harder I allow the Klingon ships to respawn in later levels.

Overall the game seemed to be stable enough now to release and I was able to play it through several times without any issues.


Instructions

Stick Left = Turn Left
Stick Right = Turn Right
Button 1 / Stick Up = Thrust
Button 2 = Boost
Button 3 = Phasers
Button 4 = Photons

Shoot the klingons, dock at the base for to replenish health etc.  Use the map at the top of right of the screen to see where the enemy are.

Gameplay Video



Download Link

https://1drv.ms/u/s!ArslbYSzzvjwiKcwUEktgs4aO3NPxQ?e=FmMVJv


Hope you enjoy playing it.


Cheers,


Andrew
#5
General Discussion / Understanding DPRAM
February 02, 2020, 02:30:57 PM
Hello Bob,

I was wondering if you could help me understand a little more about what could be consuming the DPRAM.  I assumed the DPRAM only contained the drawlist and if I ran a ClearScreen command this would clear the drawlist and free up all the DPRAM.  However this doesn't seem to be the case so I was wondering what else fills up the DPRAM?

Finally is there a way to completely clear the DPRAM.  This could be really useful.  For example I have a hi score screen which I show, then I flip to another screen.  It seems even after removing the sprites and performing a ClearScreen the memory isnt cleared when I flip between these two screens.


Thanks,


Andrew
#6
General Discussion / Re: Just saying hello
January 29, 2020, 03:50:56 AM
Looks good so far.  Will be interested to see this develop :)
#7
Hi Bob,

You're right.  There Wrap isn't any better than just using mod.  The only reason I use it to make my code more readable.  Functionally they do exactly the same thing, so its not issue if it's not added :)

Cheers,


Andrew
#8
Feature Requests and Bug Reports / Some handy functions
January 26, 2020, 09:15:38 AM
Hello,

I've written some very simple functions I needed for my game, but was wondering if they would make sense adding to the core GSBasic language.


Function Wrap(num,maxnum) 'Wraps a number e.g. providing an angle greater than 360 would wrap around to angle between 0 and 360
Return num Mod maxnum 'Example Wrap(405,360) would return 45
EndFunction

Function Sgn(innumber) 'Returns the sign of a number e.g. Sgn(-20.32) would return -1
If innumber < 0 Then
Return -1
Else
If innumber = 0 Then
Return 0
Else
Return 1
Endif
Endif
Endfunction

Function Rnd(maxamount) 'Return a random number between 0 and max amount
Return Rand() Mod maxamount
EndFunction

Function RndRange(_min,_max) 'Return a random number between _min and _max amount
spread=_max - _min
result = _min + (Rand() Mod spread)
Return result
EndFunction

function Clamp(_num,_minimum,_maximum) 'Keeps a number within a given range
if _num < _minimum then
return _minimum
else
if _num > _maximum then
return _maximum
else
return _num
endif
endif
EndFunction

Function DegToRad(radians)                           'Converts Degrees to Radians
Return radians * 0.0174533
EndFunction

Function RadToDeg(deg)                                'Converts Radians to Degrees
Return deg / 0.0174533
EndFunction

Function dCos(degrees)                                  'Cos using degrees as an input
Return cos(DegToRad(degrees))
EndFunction

Function dSin(degrees)                                   'Sin using degrees as an input
Return sin(DegToRad(degrees))
EndFunction


Might be nice to have Tan, Atan, and Atan2 function accepting degrees as well if possible?
I personally find degrees easier to visualise than radians so for my simple brain.

Cheers,


Andrew
#9
General Discussion / Getting to most out of DPRAM
January 21, 2020, 07:13:19 AM
Hello All

I've been playing around with my Vectrex32 for a week or too now and I'm really enjoying it.  I knew at some point I would find some limits and I have.  The current challenge I have is running out of DPRAM.  I was wondering if anyone had any tips on squeezing the most out of it. 

My thoughts so far are.

1) Implement a LOD system.
2) merge as many draw calls as position e.g. if I have three boxes to draw at the same location each time then just create one sprite which has the draw commands to draw three boxes, instead of three sprites.
3) if an object is behind the camera then deactivate it.  Not sure if this is already handled by the Vectrex32?
4) Reduce model lines as much as possible.

Are there any other options / tricks that other people use?

Cheers



Andrew
#10
Game Swap / Re: vxtron32 beta 1
January 18, 2020, 06:11:56 PM
I've seen a couple of the videos you posted on this and it looks awesome.  It looked so good I bought myself a Vectrex32 to play around with. Hope to get some time tomorrow to download it and give it a spin :)
#11
General Discussion / Re: Camera Position?
January 15, 2020, 06:13:10 PM
That makes perfect sense.  Thanks Bob.
#12
General Discussion / Camera Position?
January 15, 2020, 05:11:49 PM
Hello,

I've looked through the manual, but maybe I missed it.  I was wondering is there a get function for retrieving the current x,y,z position of the camera?

Thanks,


Andrew
#13
I would like to second this request.  Im writing a little library of functions that I would like to use time and time again in my projects and I would like to hive these off into a separate include file to keep them away from the main game code :)
#14
Thanks Bob.  This is good to know.  I'm loving playing with the Vectrex32 and hope to share some creations in the coming months as I get more proficient.

Cheers


Andrew
#15
Hello

I've had my Vectrex32 for a few days now and I feel I'm getting somewhere now :).  One question I had though is how is the memory managed?  Is there a garbage collector that manages unassigned variables / arrays etc.  Just looking for tips on making sure I don't create any memory leaks etc?

Cheers


Andrew