"tech" demo: motor-engine 001

Started by stef, October 31, 2005, 05:49:31 PM

Previous topic - Next topic

stef

Hi!

This is my first program!

It shows something like a machine.
It is not quite correct, but it works.

Some remarks:

Mouse controlled
Realtime calculation (no look-up tables)
Graphics of Playbasic (no extern graphics to load)
"Aquarium-Effect" by using alpha-blending (SpriteAlphaLevel)
Rotation-speed goes from 1 - 12 (degrees)


Greetings
stef



PlayBASIC Code: [Select]
; PROJECT : motor-engine 001
; AUTHOR : stef
; CREATED : 26.10.2005
; EDITED : 31.10.2005
; ---------------------------------------------------------------------
RemStart

Demo

This program shows something like a machine
Some remarks:

Mouse controlled
Realtime calculation (no look-up tables)
Graphics of Playbasic (no extern graphics to load)
"Aquarium-Effect" by using alpha-blending (SpriteAlphaLevel)
Rotation-speed goes from 1 - 12 (degrees)


RemEnd


;GRAPHICS

;cylinder housing back

cyl_back_image=GetFreeImage()
CreateImage cyl_back_image,100,160
RenderToImage cyl_back_image

For x=0 To 49
BoxC 0+x,0,100-x,160,1,RGB(3*x,3*x,3*x)
Next x
BoxC 0,0,10,160,1,RGB(20,20,20)
BoxC 90,0,100,160,1,RGB(20,20,20)
BoxC 0,0,100,10,1,RGB(20,20,20)

PrepareFXImage cyl_back_image
cyl_back_sprite=GetFreeSprite()
CreateSprite cyl_back_sprite
SpriteImage cyl_back_sprite,cyl_back_image
SpriteDrawMode cyl_back_sprite,2


;cylinder housing front

cyl_front_image=GetFreeImage()
CreateImage cyl_front_image,100,160
RenderToImage cyl_front_image

For x=0 To 49
BoxC 0+x,0,100-x,160,1,RGB(30+3*x,30+3*x,30+3*x)
Next x

For x=0 To 49
BoxC 0+x,0,100-x,10,1,RGB(3*x,3*x,3*x)
Next x

PrepareFXImage cyl_front_image
cyl_front_sprite=GetFreeSprite()
CreateSprite cyl_front_sprite
SpriteImage cyl_front_sprite,cyl_front_image
SpriteDrawMode cyl_front_sprite,2+4


;piston

piston_image=GetFreeImage()
CreateImage piston_image,80,70
RenderToImage piston_image


BoxC 30,0,50,50,1,RGB(40,40,40)
CircleC 40,50,12,1,RGB(40,40,40)
CircleC 40,50,8,1,RGB(30,30,50)

For x=0 To 39
BoxC 0+x,0,80-x,30,1,RGB(3*x,3*x,3*x)
Next x

PrepareFXImage piston_image
piston_sprite=GetFreeSprite()
CreateSprite piston_sprite
SpriteImage piston_sprite,piston_image
SpriteDrawMode piston_sprite,2

;"pressure"
pressure_image=GetFreeImage()
CreateImage pressure_image,79,160
RenderToImage pressure_image

BoxC 0,0,80,60,1,RGB(250,0,0)

PrepareFXImage pressure_image
pressure_sprite=GetFreeSprite()
CreateSprite pressure_sprite
SpriteImage pressure_sprite,pressure_image
SpriteDrawMode pressure_sprite,2+1024


;flywheel

flywheel_image=GetFreeImage()
CreateImage flywheel_image,200,200
RenderToImage flywheel_image


CircleC 100,100,100,1,RGB(40,40,40)
CircleC 100,100,90,1,RGB(80,80,80)

CircleC 140,60,25,1,0
CircleC 140,140,25,1,0
CircleC 60,60,25,1,0
CircleC 60,140,25,1,0

CircleC 100,100,25,1,RGB(50,50,50)
CircleC 100,100,8,1,RGB(30,30,30)

PrepareFXImage flywheel_image
flywheel_sprite=GetFreeSprite()
CreateSprite flywheel_sprite
SpriteImage flywheel_sprite,flywheel_image
SpriteDrawMode flywheel_sprite,2
CenterSpriteHandle flywheel_sprite

;rod

rod_image=GetFreeImage()
CreateImage rod_image,205,21
RenderToImage rod_image

BoxC 14,6,191,14,1,RGB (150,20,20)
CircleC 10,10,10,1,RGB (150,20,20)
CircleC 191,10,10,1,RGB (150,20,20)
CircleC 10,10,6,1,RGB (30,30,30)
CircleC 191,10,6,1,RGB (30,30,30)

PrepareFXImage rod_image
rod_sprite=GetFreeSprite()
CreateSprite rod_sprite
SpriteImage rod_sprite,rod_image
SpriteDrawMode rod_sprite,2
SpriteHandle rod_sprite,-10,-10

;startbutton

startbutton_image=GetFreeImage()
CreateImage startbutton_image, 50,50
RenderToImage startbutton_image

Login required to view complete source code

kevin

Stef,

 That is simply Excellent... I'm actually stunned!

 Where did you get the idea for that from ?

empty

indeed, that's awesome (idea & realisation)!

Draco9898

DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

stef

Hi!

Thanks for response.

Just working on another demo named "fireworks" and thinking about creating a game. Title: "Cool Sliding" . Maybe a funracer.

But must still study  examples and commands.

Btw.: Have just purchased PlayBasic.

Greetings
stef

stef

Hi!

Fixed a bug in the code above.

The "Transmission" wasn't shown.
Wrong value of SpriteDrawMode!

Should work now correctly.

Sorry
stef

tomazmb

Hello,

It really is a fantastic demo. Nice work.

Have a nice day,

Tomaz
My computer specification:

AMD Athlon 64 2800+
MB ASUS K8V Socket 754 VIA K8T800
SB Audigy 2
3 GB RAM DDR 400 MHz PQI
AGP NVIDIA GeForce 7600GT 256 MB-Club 3D
Windows XP Pro SP2
DirectX 9.0c