Author Topic: Star Backgound  (Read 877 times)

Offline Ashish

  • The joy of coding is endless.
Re: Star Backgound
« Reply #30 on: June 17, 2018, 12:55:41 PM »
Thanks Guys! :D
I thought that the fire was not looking good in space. It must be somewhat neon light blue in color to give a nitro booster effect to spaceship.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


aKFrameWork - http://bit.ly/aKFrameWork
Menu System - http://bit.ly/guiMenuBar
p5.js in QB64 - http://bit.ly/p5jsbas

@KingOfCoders

Re: Star Backgound
« Reply #31 on: June 17, 2018, 07:05:09 PM »
You know how much fun a project is by the number of replies/updates.

Thanks to a post from bplus:
https://www.qb64.org/forum/index.php?topic=278.msg1642#msg1642

I modified the code to have the planets rotate properly and it looks great (in my opinion).

I have the planets rotate at different speeds just for enjoyment.

fps (Frames per Second) can be turned on/off with 'F'

Code: [Select]
_TITLE "Space the Final Frontier"

RANDOMIZE TIMER

DIM Touch AS STRING

DIM SHARED frameRate AS INTEGER
DIM SHARED frameCount AS INTEGER

DIM SHARED frameTime AS STRING
frameTime = RIGHT$(TIME$, 2)

DIM SHARED frameView
frameView = 0

DIM SHARED modFire AS _BYTE
modFire = 0

DIM SHARED fireSizeX, fireSizeY
fireSizeX = 120
fireSizeY = 19

DIM SHARED fireBuffer(fireSizeX, fireSizeY), colorPal(255) AS _UNSIGNED LONG, fuelControl
fuelControl = 0.23

'creating our palette for fire
FOR i = 255 TO 0 STEP -1
  IF i <= 255 AND i >= 200 THEN 'white to yellow
    colorPal(i) = _RGB32(map(i, 255, 200, 255, 255), map(i, 255, 200, 255, 242), map(i, 255, 200, 255, 0))
  ELSEIF i <= 201 AND i >= 79 THEN 'yellow to orange
    colorPal(i) = _RGB32(map(i, 201, 79, 255, 221), map(i, 201, 79, 242, 140), map(i, 201, 79, 0, 0))
  ELSEIF i <= 89 AND i >= 79 THEN 'orange to dark orange red
    colorPal(i) = _RGB32(map(i, 89, 79, 221, 183), map(i, 89, 79, 140, 45), map(i, 89, 79, 0, 0))
  ELSEIF i <= 78 AND i >= 0 THEN 'dark orange red to transparent
    colorPal(i) = _RGBA32(map(i, 78, 0, 183, 0), map(i, 78, 0, 45, 0), map(i, 78, 0, 0, 0), map(i, 78, 0, 255, 0))
  END IF
NEXT

' \/\/\/\/\/\/\/\/\/\/\/\/
' Screen Width and Height
' /\/\/\/\/\/\/\/\/\/\/\/\
DIM SHARED sWidth AS INTEGER
DIM SHARED sHeight AS INTEGER
sWidth = 800
sHeight = 600

SCREEN _NEWIMAGE(sWidth, sHeight, 32)

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Stars Background and the Starship
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
DIM SHARED starBack AS LONG
DIM SHARED Starship AS LONG

' Stars Background:
' https://www.qb64.org/forum/index.php?PHPSESSID=fe200737599194549d14a890bf46be14&topic=250.0
starBack = _LOADIMAGE(".\images\Stars.png")
_PUTIMAGE (0, 0), starBack

' Starship:
' http://www.clipartlord.com/category/space-clip-art/spaceship-clip-art/
Starship = _LOADIMAGE(".\images\Starship.png")
_CLEARCOLOR _RGB(0, 0, 0), Starship

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Used to make sure Starship doesn't go offscreen
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
wShip = sWidth - 400
hShip = sHeight - 170

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Starship Location (Centered)
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
DIM SHARED shipX AS INTEGER
DIM SHARED shipY AS INTEGER
shipX = sWidth \ 2 - 200
shipY = sHeight \ 2 - 85

' \/\/\/\/\/\/\/\/\/\/\/
' Speed of the Starship
' /\/\/\/\/\/\/\/\/\/\/\
DIM SHARED warpSpeed AS INTEGER
warpSpeed = 2

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Celestial Objects (Stars and Planets)
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
TYPE Celestial
  ' Location
  x AS INTEGER
  y AS INTEGER

  ' Size
  w AS INTEGER
  h AS INTEGER

  ' Rotation
  r AS SINGLE

  ' Planet used
  used AS INTEGER

  ' Planet Spins
  spin AS INTEGER
  speed AS INTEGER

  image AS LONG
END TYPE

' \/\/\/\/\/\/\/\/
' Stars Background
' /\/\/\/\/\/\/\/\
DIM SHARED Stars(2) AS Celestial

Stars(1).x = 0
Stars(2).x = 800

Stars(1).image = _NEWIMAGE(800, 600, 32)
_PUTIMAGE (0, 0), starBack, Stars(1).image

Stars(2).image = _NEWIMAGE(800, 600, 32)
Starfield
Frontier

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Display text while Planets load
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Touch = "Loading Planet Data...."

y = sHeight \ 2 - 8
x = sWidth \ 2 - (LEN(Touch) * 4)
_PRINTSTRING (x, y), Touch

DIM SHARED PlanetView(4) AS INTEGER

DIM SHARED Planet(40) AS Celestial

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Load all the planets (40 total)
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
FOR p = 1 TO 40
  ' Planets:
  ' http://www.clipartlord.com/category/space-clip-art/planets-clip-art/
  Planet(p).image = _LOADIMAGE(".\images\Planet" + RIGHT$("0" + LTRIM$(STR$(p)), 2) + ".png")
  _CLEARCOLOR _RGB(0, 0, 0), Planet(p).image

  ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  ' Get the Width and Height of the planet
  ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  Planet(p).w = _WIDTH(Planet(p).image)
  Planet(p).h = _HEIGHT(Planet(p).image)
NEXT

' \/\/\/\/\/\/\/\/\/\/\/\/\/
' Starship enters the scene
' /\/\/\/\/\/\/\/\/\/\/\/\/\
FOR x = -400 TO shipX STEP 10
  IF modFire = 1 THEN
    'fire
    FOR fy = 3 TO fireSizeY - 2
      fireBuffer(fireSizeX - 2, fy) = INT(RND * 128) + 128
    NEXT
    FOR fy = 3 TO fireSizeY - 2
      FOR fx = 0 TO fireSizeX - 2
        fireBuffer(fx, fy) = (fireBuffer(fx + 1, fy - 1) + fireBuffer(fx + 1, fy) + fireBuffer(fx + 2, fy) + fireBuffer(fx + 1, fy + 1)) * (fuelControl + .018327)
    NEXT fx, fy
  END IF

  _PUTIMAGE (0, 0), starBack

  IF modFire = 1 THEN
    'rendering fire
    FOR fy = 0 TO fireSizeY
      FOR fx = 0 TO fireSizeX
        PSET (fx + x + 115 - fireSizeX + 2, fy + shipY + 100), colorPal(INT(fireBuffer(fx, fy)))
    NEXT fx, fy
  END IF

  _PUTIMAGE (x, shipY), Starship

  _DISPLAY
  _LIMIT 30
NEXT

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Show the animations until ESC is pressed
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
WHILE Touch <> CHR$(27)
  Background

  ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  ' Checks to see if a key is pressed
  ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  Touch = INKEY$
  IF Touch <> "" THEN
    ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    ' Keys 0-9 changes the warpspeed
    ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    IF ASC(Touch) > 47 AND ASC(Touch) < 58 THEN warpSpeed = VAL(Touch)

    ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
    ' M key will add the fire mod
    ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
    IF UCASE$(Touch) = "M" THEN
      IF modFire = 0 THEN modFire = 1 ELSE modFire = 0
    END IF

    ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    ' Home key centers the Starship
    ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    IF Touch = CHR$(0) + CHR$(71) THEN
      shipX = sWidth \ 2 - 200
      shipY = sHeight \ 2 - 85
    END IF

    ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    ' Up and Down Arrow Keys moves the Starship
    ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    IF Touch = CHR$(0) + CHR$(72) THEN
      shipY = shipY - warpSpeed
      IF shipY < 0 THEN shipY = 0
    END IF

    IF Touch = CHR$(0) + CHR$(80) THEN
      shipY = shipY + warpSpeed
      IF shipY > hShip THEN shipY = hShip
    END IF
  END IF

  IF UCASE$(Touch) = "F" THEN
    IF frameView = 0 THEN frameView = 1 ELSE frameView = 0
  END IF

  IF frameView = 1 THEN Framed

  _DISPLAY
  _LIMIT 60
WEND
END

FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
END FUNCTION

SUB Background
' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Places the stars Backgrounds
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
_PUTIMAGE (Stars(1).x, 0), Stars(1).image
_PUTIMAGE (Stars(2).x, 0), Stars(2).image

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Show planet(s)  (if available)
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
FOR v = 1 TO 2
  IF PlanetView(v) > 0 THEN
    ViewPlanet PlanetView(v), v
  END IF
NEXT

IF modFire = 1 THEN
  acc = (warpSpeed + 1) * .001905#

  'fire
  FOR fy = 3 TO fireSizeY - 2
    fireBuffer(fireSizeX - 2, fy) = INT(RND * 128) + 128
  NEXT

  FOR fy = 3 TO fireSizeY - 2
    FOR fx = 0 TO fireSizeX - 2
      fireBuffer(fx, fy) = (fireBuffer(fx + 1, fy - 1) + fireBuffer(fx + 1, fy) + fireBuffer(fx + 2, fy) + fireBuffer(fx + 1, fy + 1)) * (fuelControl + acc)
  NEXT fx, fy

  'rendering fire
  FOR fy = 0 TO fireSizeY
    FOR fx = 0 TO fireSizeX
      'PRINT INT(fireBuffer(fx, fy))
      PSET (fx + shipX + 115 - fireSizeX + 2, fy + shipY + 100), colorPal(INT(fireBuffer(fx, fy)))
  NEXT fx, fy
END IF

' \/\/\/\/\/\/\/\/\/
' Show the Starship
' /\/\/\/\/\/\/\/\/\
_PUTIMAGE (shipX, shipY), Starship

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Have the background shift left by warpspeed
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Stars(1).x = Stars(1).x - warpSpeed
Stars(2).x = Stars(2).x - warpSpeed

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' When the background reaches the end reset background
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
IF Stars(2).x < 0 THEN
  Stars(1).x = 0
  Stars(2).x = 800

  ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  ' Put the second image on the first to keep the animation proper
  ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  _PUTIMAGE (0, 0), Stars(2).image, Stars(1).image

  Starfield
END IF
END SUB

SUB Frontier
' \/\/\/\/\/\/\/\/\/\/\/\/\/
' Choose a Planet to display
' /\/\/\/\/\/\/\/\/\/\/\/\/\
'tag1:
p1 = INT(40 * RND) + 1
'IF Planet(p1).used = 1 THEN GOTO tag1

' \/\/\/\/\/\/\/\/\/\/\/\/
' Get the Width and Height
' /\/\/\/\/\/\/\/\/\/\/\/\
w = Planet(p1).w
h = Planet(p1).h

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Make sure planet isn't going off the screen
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
x1 = INT((sWidth - w) * RND)
y1 = INT((sHeight - h) * RND)

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Set the Planet as used and save the location
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
PlanetView(1) = p1

Planet(p1).x = 800 + x1
Planet(p1).y = y1

Planet(p1).used = 1
IF p1 < 29 THEN
  Planet(p1).spin = INT(2 * RND)
  IF Planet(p1).spin = 1 THEN
    Planet(p1).speed = 3 * (INT(2 * RND) + 1)
  END IF
END IF

IF INT(2 * RND) = 1 THEN
  p2 = INT(40 * RND) + 1

  w = Planet(p2).w
  h = Planet(p2).h

  IF p2 <> p1 THEN
    IF w < Planet(p1).w AND h < Planet(p1).h THEN
      x2 = INT((sWidth - w) * RND)
      y2 = INT((sHeight - h) * RND)
    END IF
  END IF

  PlanetView(2) = p2

  Planet(p2).x = 800 + x2
  Planet(p2).y = y2

  Planet(p2).used = 1

  IF p2 < 29 THEN
    Planet(p2).spin = INT(2 * RND)
    IF Planet(p2).spin = 1 THEN
      Planet(p2).speed = 3 * (INT(2 * RND) + 1)
    END IF
  END IF
END IF
END SUB

SUB Starfield
' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Reset the background and rotate to make things different
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
SELECT CASE INT(4 * RND)
  CASE 0: _PUTIMAGE (0, 0), starBack, Stars(2).image
  CASE 1: _PUTIMAGE (799, 0)-(0, 599), starBack, Stars(2).image
  CASE 2: _PUTIMAGE (0, 599)-(799, 0), starBack, Stars(2).image
  CASE 3: _PUTIMAGE (799, 599)-(0, 0), starBack, Stars(2).image
END SELECT
END SUB

SUB ViewPlanet (p, v)
w = Planet(p).w
h = Planet(p).h

x1 = Planet(p).x
y1 = Planet(p).y

IF Planet(p).spin = 0 THEN
  _PUTIMAGE (x1, y1), Planet(p).image
ELSE
  Rotate x1, y1, Planet(p).image, Planet(p).r

  Planet(p).r = Planet(p).r + Planet(p).speed
  IF Planet(p).r > 359 THEN Planet(p).r = 0
END IF

x1 = x1 - warpSpeed
Planet(p).x = x1

IF x1 + w < 0 THEN
  PlanetView(v) = 0
  Planet(p).used = 0

  ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
  ' Add Planets to the animation
  ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
  Frontier
END IF
END SUB

SUB Rotate (X AS INTEGER, Y AS INTEGER, Image AS LONG, Rotation AS SINGLE)
DIM px(3) AS SINGLE: DIM py(3) AS SINGLE

W& = _WIDTH(Image&): H& = _HEIGHT(Image&)
px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2

sinr! = SIN(-Rotation / 57.2957795131): cosr! = COS(-Rotation / 57.2957795131)

FOR i& = 0 TO 3
  x2& = (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) + Y
  px(i&) = x2&: py(i&) = y2&
NEXT

_MAPTRIANGLE (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MAPTRIANGLE (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
END SUB

SUB Framed
IF RIGHT$(TIME$, 1) = frameTime THEN
  frameCount = frameCount + 1
ELSE
  frameRate = frameCount

  frameCount = 0
  frameTime = RIGHT$(TIME$, 1)
END IF

_PRINTSTRING (4, 8), STR$(frameRate)
END SUB
« Last Edit: June 17, 2018, 07:08:32 PM by Code Hunter »

Offline bplus

  • B = B + geberation
Re: Star Backgound
« Reply #32 on: June 18, 2018, 10:29:40 AM »
Ha! I thought it was Love that makes the worlds go round.

How does it make you feel with all this planet making and turning? :D
B = B + ...

Re: Star Backgound
« Reply #33 on: June 18, 2018, 01:27:02 PM »
I would feel MUCH better if the planets actually 'spins' instead of rotates as a real planet would.  Makes things more accurate.

Offline bplus

  • B = B + geberation
Re: Star Backgound
« Reply #34 on: June 18, 2018, 01:34:11 PM »
Yeah, they made my head spin but a view at pole of earth would show same spinning (maybe not so fast), actually I was offering RotoZoom2 for helm control to point ship in different directions, but then you'd have to make star background adjust to new direction. You could then draw an infinite space by generating new star systems... extending the universe out to infinity... how do you feel about that? ;D Then the trick would be to repeat the same star pattern if you turn the ship around!
« Last Edit: June 18, 2018, 01:36:13 PM by bplus »
B = B + ...

Offline bplus

  • B = B + geberation
Re: Star Backgound
« Reply #35 on: June 18, 2018, 03:47:14 PM »
Oh hey a crazy idea, make a rectangular map of the planet, code it to a cylinder (connect the left edge to the right with mod) and then map the upper and lower edges to a single point, the poles, add snow and spin.
B = B + ...

Offline johnno56

  • Live long and prosper.
Re: Star Backgound
« Reply #36 on: June 18, 2018, 07:10:32 PM »
bplus,

I had that thought as well. A rectangular image converted to an animated sphere. Already done that ages ago... Gimp has the ability to do that and to generate an animated gif. It's easy enough to extract the many 'frames' but would be even easier if QB64 has the ability to display animated gif's.

If I can find my old tutorial I will post it... Hang on... I can't. "attachments' do not cater for files... Is someone going to fix that little issue? Never mind. I create a link. Give me a little while to find my files... lol

J
Logic is the beginning of wisdom.

Offline johnno56

  • Live long and prosper.
Re: Star Backgound
« Reply #37 on: June 18, 2018, 07:37:09 PM »
Done.

Here is the link to the tutorial: http://www.paintshopprotutorials.co.uk/html/spinning_globe_animation_gimp.html

Here are the links to the files I used.
https://www.dropbox.com/s/ain0yxptec30i1b/flag.png?dl=0 (image)
https://www.dropbox.com/s/0ofsdv7xnihe2kv/flag.gif?dl=0 (gif - 100 frames)

The whole process took only a few minutes. (NB: I deliberately used a 'square' image. Produced a better globe)

I hope this helps...

J

ps: Just finished "Mars". Enjoy.

https://www.dropbox.com/s/x2puc7x1x315r2a/mars.png?dl=0 (image)
https://www.dropbox.com/s/z1yd3uj57cgfuch/mars.gif?dl=0 (gif - 100 frames)
« Last Edit: June 18, 2018, 07:54:55 PM by johnno56 »
Logic is the beginning of wisdom.

Offline bplus

  • B = B + geberation
Re: Star Backgound
« Reply #38 on: June 19, 2018, 12:50:55 AM »
Hi Johnno,

Where are you getting the rectangle images?

Mars is fantastic except for the unseemly seam. There is probably some way to blend the two ends mainly with colors?

I started looking into converting a rectangle to sphere image and learned word tessellation and triangle strips. Saw some fairly reasonable trig equations for the points. Maybe halfway home?
http://hugi.scene.org/online/hugi27/hugi%2027%20-%20coding%20corner%20polaris%20sphere%20tessellation%20101.htm
« Last Edit: June 19, 2018, 12:59:37 AM by bplus »
B = B + ...

Re: Star Backgound
« Reply #39 on: June 19, 2018, 01:14:16 AM »
An idea (if it is possible) would be to take a texture for a planet and using maptriangle and creating a circle that is the planet.

Would that be possible?  It can create a square (3D cube).

I can't even begin figuring out how maptriangle works so I won't even try to figure out if it can be done.

Offline johnno56

  • Live long and prosper.
Re: Star Backgound
« Reply #40 on: June 19, 2018, 01:35:04 AM »
Rectangular images? Google. "flat map mars" etc. Using Gimp's in built Sphere Animator makes a 'traditional' sphere if the image is 'stretched' out to a square. Any image/texture can be used. The more frames used (10 frames per second is the slowest) will give you a smoother rotation at the cost of more memory.... The Mars example works quite well except for, as you rightly pointed out, the 'seam'. Gimp is quite capable in producing 'seamless' images, but for an image as complex as Mars, may be a 'bit of a stretch' - no pun intended... lol

Here is a better one by Nasa:

https://www.dropbox.com/s/jix1n1mhswnp2q2/mars0_src.jpg?dl=0 (image)
https://www.dropbox.com/s/u1p8ueq4dlj6ef2/mars2.gif?dl=0 (gif - 100 frames)
« Last Edit: June 19, 2018, 01:53:42 AM by johnno56 »
Logic is the beginning of wisdom.

Re: Star Backgound
« Reply #41 on: June 19, 2018, 02:17:51 AM »
Very nice.  I'm using a much simpler stars BG in the Asteroids-based game I'm currently making.  I want to upload it as a work in progress, but I'm confused about how the whole Linux thing works.  With Windows, I'd compile it, there would be the .exe file, and it would be super-simple to run it.  In Ubuntu, I don't even see an extension on the filename.  I definitely want the game usable in both Windows and Linux!  Should I just let the user take the source and compile it?  Am I over-complicating this?

I love the way my stars move independently of the separate nebula/cloud BG as the ship flies around.  I hope I'll get to share it here soon.
« Last Edit: June 19, 2018, 02:53:36 AM by SirCrow »
I may not always finish what I've started....

Re: Star Backgound
« Reply #42 on: June 19, 2018, 03:04:25 AM »
Here is a quick little Lazy Man's (or really Crazy Man's) Planet Maker from a texture.

Although the main part of this program works fine, when it is ready to show the new planet, it crashes with "illegal function call"

Line 83 reads:
Code: [Select]
_PUTIMAGE (tx, ty), Mars(f), 0
Why it crashes is beyond me and it happens almost all the time with _PutImage (at least for me).

<insert fowl language about _Putimage here>

Anyway maybe someone can help me on this.

Here is the code that takes a square (480x480) texture and creates a round planetoid from it.

Code: [Select]
_TITLE "Planet Maker - Mars"
SCREEN _NEWIMAGE(500, 500, 32)

' \/\/\/\/\/\/\/\/\/
' Load texture image
' /\/\/\/\/\/\/\/\/\
Texture = _LOADIMAGE(".\images\mars.png")

' \/\/\/\/\/\/\/\/\/\/
' Center of the screen
' /\/\/\/\/\/\/\/\/\/\
DIM SHARED cw AS INTEGER
DIM SHARED ch AS INTEGER
cw = 250
ch = 250

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Width and Height of the texture
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
w = 480
h = 480

' \/\/\/\/\/\/\/\/\/\/\/\/\/
' Location to put the images
' /\/\/\/\/\/\/\/\/\/\/\/\/\
tx = cw - w \ 2
ty = ch - h \ 2

' \/\/\/\/\/\/
' Mars images
' /\/\/\/\/\/\
DIM SHARED Mars(w) AS LONG

' \/\/\/\/\/\/\/\/\/
' Start with frame 1
' /\/\/\/\/\/\/\/\/\
frames = 1

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Scroll the texture the width of the texture
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
FOR x = 0 TO w - 1 STEP 10

  ' \/\/\/\/\/\/\/\/\/\/\/
  ' Draw to the Mars image
  ' /\/\/\/\/\/\/\/\/\/\/\
  _DEST Mars(frames)
  _PUTIMAGE (tx, ty), Texture, , (x, 0)-(w, h)
  _PUTIMAGE (tx + w - x, ty), Texture, , (1, 0)-(x, h)

  ' \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  ' Remove all extra image data from outside the circle
  ' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  FOR r = 241 TO 341 STEP 0.01
    CIRCLE (cw, ch), r, _RGB(0, 0, 0)
  NEXT

  ' \/\/\/\/\/\/\/\/\/\/
  ' Increase frame count
  ' /\/\/\/\/\/\/\/\/\/\
  frames = frames + 1
NEXT

' \/\/\/\/\/\/\/\/\/\/\/\/\/
' Set destination to screen
' /\/\/\/\/\/\/\/\/\/\/\/\/\
_DEST 0

' \/\/\/\/\/\/\/\/
' Erase the screen
' /\/\/\/\/\/\/\/\
LINE (0, 0)-(800, 600), _RGB(0, 0, 0), BF

' \/\/\/\/\/\/\/\/\/\/\/\/\/\/
' Repeat until ESC is pressed
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
WHILE INKEY$ <> CHR$(27)

  ' \/\/\/\/\/\/\/\/\/\/
  ' Show the planet Mars
  ' /\/\/\/\/\/\/\/\/\/\
  FOR f = 1 TO frames
    _PUTIMAGE (tx, ty), Mars(f), 0

    _DISPLAY
    _LIMIT 30
  NEXT
WEND

Mars texture: https://www.dropbox.com/s/x2puc7x1x315r2a/mars.png?dl=0

Edit: Add the following lines:

Code: [Select]
DIM SHARED Mars(w) AS LONG
FOR f = 1 TO w
  Mars(f) = _NEWIMAGE(w, h)
NEXT
« Last Edit: June 19, 2018, 03:31:05 AM by Code Hunter »

Re: Star Backgound
« Reply #43 on: June 19, 2018, 03:08:05 AM »
Very nice.  I'm using a much simpler stars BG in the Asteroids-based game I'm currently making.  I want to upload it as a work in progress, but I'm confused about how the whole Linux thing works.  With Windows, I'd compile it, there would be the .exe file, and it would be super-simple to run it.  In Ubuntu, I don't even see an extension on the filename.  I definitely want the game usable in both Windows and Linux!  Should I just let the user take the source and compile it?  Am I over-complicating this?

I love the way my stars move independently of the separate nebula/cloud BG as the ship flies around.  I hope I'll get to share it here soon.

Linux doesn't use an extension.  Just archive the file and any needed images or files and you can share it.  Running linux the user would extract the file(s) and then run the executable.

Offline bplus

  • B = B + geberation
Re: Star Backgound
« Reply #44 on: June 19, 2018, 10:02:47 AM »
Hi SirCrow,

I sure don't need the exe (Windows) and much prefer the source to compile.
B = B + ...