LoadNewShape
ShapeIndex = LoadNewShape(Filename$)
 
Parameters:

    Filename$ = The filename of the shape you wish to load
Returns:

    ShapeIndex = The Index of the shape
 

      LoadNewShape reads an shape file from disc into PlayBASIC's shape memory. You must provide the command with the full folder path and filename of the shape you wish to load and if the shape exists it'll return the shape index to you. If the file doesn't exist it'll return a zero.



FACTS:


      * Load + Save Shape are part of the Shape extension Library. In order to use them, make sure you include the shape extension library at the top of your program if you need them. Eg. #include "Shape"



Mini Tutorial:


      This example creates a convex shape, saves it disc and the reloads it using the Load and save shape commands

  
; Include the Shape extension library
  #Include "Shape"
  
; Create a convert shape.
  CreateConvexShape 1,50,7
  
; The Filename of our test load/save file
  Filename$="C:Test_PlayBasic_LoadAndSaveShape.Dat"
  
  
; Save the shape to the C: drive
  SaveShape Filename$,1
  
  
; Load the shape file
  MySHape=LoadNewShape(Filename$)
  
  
; Display the shapes
  DrawShape 1,100,100,2
  DrawShape MyShape,300,100,2
  
; display the index of the newly loaded shape
  Print "MyShapeIndex="+Str$(MyShape)
  
  
; Delete the temp file,
  DeleteFile Filename$
  
  
  
  
; Refresh the screen abnd wait for a key press
  Sync
  WaitKey
  



This example would output.

  
  no Text output
  




Example:



      This example loads a premade shape from the MEDIA folder. The shape was created as collision outline for the ship.bmp picture in the help media folder also. The Shape was created using PlaySHAPE. It's FREE and can be found on the PlayBASIC.com web site under the tools section.

 
Example Source: Download This Example
; -------------------------------------------------
; include the Shape 'extras' library in our program
; -------------------------------------------------
  #Include "shape"
  
  
; ------------------------------------------------
; Load the shape into memory, the shape file is located
; in the MEDIA folder of the help system, so we're looked
; back two folder from where this example is saved,
; ------------------------------------------------
  
  ShipShape=LoadNewShape("..\../Media/ship.Shape")
  
  
; ------------------------------------------------
; Offset the verts in the shape so it's centered around a centeral point
; ------------------------------------------------
  ShiftShape ShipShape,-32,-32
  
  
; ------------------------------------------------
; Main Loop of Program
; ------------------------------------------------
  
  Do
     
   ; clear the screen to black
     Cls
     
   ; Rotate the shapes
     Angle#=WrapAngle(Angle#,1)
     RotateShape ShipShape,Angle#,1
     
     
   ; Draw this vector shape on screen (Dot Mode)
     DrawShape ShipShape,100,100,0
     
   ; Draw this vector shape on screen (Line Mode)
     DrawShape ShipShape,200,100,1
     
   ; Draw this vector shape on screen (Filled)
     DrawShape ShipShape,300,100,2
     
     
   ; show the screen
     Sync
     
   ; loop back to the Do, to keep program running until
   ; a key is pressed
  Loop ScanCode()<>0
  
  
  
 
Related Info: #Include | CopyShape | CreateConvexShape | CreateShape | LoadShape | NewConvexShape | NewShape | SaveShape | ShiftShape :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com