PDA

View Full Version : Stars and Ufo



peter
20-02-2014, 22:14
Hi,


new api.inc.
new are:


SetColorKey (long)
LoadImage (string, long)
DrawImage (long,long,long,long,long,long)
DeleteImage(long)
FreeImage()
GetImagePixel(long,long,long)
SetImagePixel(long,long,long,long)

I wanted a bitmap system for games, later.

Example: Stars and Ufo


Uses "ui"
#INCLUDE "api.inc"


DWord hwnd = Canvas_Window("api_app",xMid(640),yMid(480),640,480)
Canvas_Attach(hwnd,0,%TRUE)
DWord hdc = Canvas_GetDC()
Canvas_Font "courier",16, %CANVAS_FONTSTYLE_BOLD


Long ufo = LoadImage "bmp/ufo2.bmp",1


Long anz, speed, xscreen, yscreen, sx, sy, i, c
anz=600 : speed=4 : xscreen=640 : yscreen=480


Dim xStern(anz) As Long
Dim yStern(anz) As Long
Dim zStern(anz) As Long

For i=1 To anz
xStern(i) = Rnd( -(xscreen/2), (xscreen/2)) *128
yStern(i) = Rnd( -(yscreen/2), (yscreen/2)) *128
zStern(i) = Rnd( speed, 255 )
Next

While IsWindow(hwnd) And KeyDown(%VK_ESCAPE)=0
Canvas_Clear 0
DrawImage ufo,224,208,192,64,0

For i=1 To anz
zStern(i) = zStern(i) -speed
If zStern(i) <= speed Then zStern(i) = 255
sx = (xStern(i) / zStern(i)) + (xscreen /2)
sy = (yStern(i) / zStern(i)) + (yscreen /2)
c = 300 - zStern(i)
Canvas_Circle sx, sy, 2, -1,Rgb(c,c,c)
Next
Canvas_Redraw
Sleep 10
Wend
FreeImages()
Canvas_Window End