Dark Bit Factory & Gravity
PROGRAMMING => Purebasic => Topic started by: Omnikam on October 30, 2015
-
Okay this is More Vomit Inducing than i wanted it to be ;D But it puts together what ive learned thus far
Okay its not Original, Yes Ive coppied lots of code, but i had to put it all together and i can asure you it was a pain :clap:
I promise, if i dont go to jail on monday for driving without a license, ill make a ripper but simple demo
resX = 800
resY = 600
xres = 320
yres = 240
sco = 0
tptr = 1
UseJPEGImageDecoder()
UsePNGImageDecoder()
InitSprite()
InitKeyboard()
OpenScreen( resX, resY, 32, "MyFirstDemo" )
ipt = LoadSprite(#PB_Any, "C64.jpg")
If InitSound() = 0
MessageRequester("Error", "Sound system not available.") : End
EndIf
If CatchMusic(0, ?Tune, ?TuneEnd-?Tune)
PlayMusic(0)
; Now, perform a nice fading...
;load font
font = LoadSprite (#PB_Any, "Charset-DNS_Antor Intruders Font 3.png") ; Load th$e font PNG as Sprite
If font = 0 ; If loading Spritefailed,
MessageRequester("Error", "Cant load font.PNG", 0) ; we alert an error and
End
; stop the application
EndIf
h$ = " "
h$ = h$ + " WELL HERE IT IS MY FIRST DEMO EVER IT WILL INDUCE SICKNESS "
h$ = h$ + "I KNOW ITS A CUT AND PASTE JOB BUT I CAN HONESTLY SAY "
h$ = h$ + "IT WAS FAR HARDER THAN THAT, I ACTUALLY LEARNED SOMETHINGS "
h$ = h$ + " OKAY WELL NOW THE THANKYOU TIME THANKS TO PADMAN, WITHOUT YOU THIS WOULDNT HAVE HAPPEN "
h$ = h$ + " THANKS TO SHOCKWAVE FOR HIS AWSOME SCROLLER, VAIN FOR FLOOR ROOTINE AND TO http://www.dbfinteractive.com "
Repeat
ExamineKeyboard()
StartDrawing(ScreenOutput())
camY.f = camY + 200
b.f = 0
For y = 0 To resY-1
w.f = -yres / y
v.f = ( resX * w - camY )
u.f = ( -xres * w + camX )
For x = 0 To resX -1
t = ((Int(u) ! Int(v) ) & 255 )
c = Int((t / resY) * y)
Plot( x, y, RGB( c, c, c ))
u = u + w
Next
b = b + resX
Next
StopDrawing()
TransparentSpriteColor(ipt,#White)
;scroller
cco = 0
For cc = 0 To 25
letter = Asc(UCase(Mid(h$, tptr+cc, 1)))-32
yCharPos = letter / 10
xCharPos = letter % 10
ClipSprite(font, xCharPos*32, yCharPos*32, 32, 32) ;the magic
TransparentSpriteColor(font,#Black) ;sets the transparacy color of the font png
DisplayTransparentSprite(font, sco+cco, 300+50*Sin((cc+cco+sco+m)/120)) ;
DisplayTransparentSprite(ipt, 0, 0)
cco = cco + 32
Next
m = m -5
sco = sco -6
;
If sco < -32
tptr = tptr + 1
sco = sco + 32
EndIf
;
If tptr > Len(h$)-30
tptr = 1
EndIf
FlipBuffers()
ClearScreen($0)
Until KeyboardPushed( #PB_Key_Escape )
For k=100 To 0 Step -1
Delay(20)
MusicVolume(0, k)
End
DataSection
Tune:
IncludeBinary "simpukka_chilli.xm" ; no need to convert it to DATA statments using bin2data, just include the file.
TuneEnd:
EndDataSection
Next
StopMusic(0)
EndIf
-
For your first Demo? That is good and Well Done :clap:
-
Yep, much better than my first try ;D
Keep coding, you are on the right way.
-
Oh wow thanks guy`s, I cant belive you say such kind thing, I felt rather ashamed of it because i rushed it out the door, i would have liked to spend a few days rather a night working on it. But im not going to rush my second one. I`m just glad you are giving up some of your time to help me with the basics :cheers:
-
Nice one Omnikam! 8)
A little vomit is good, it's tradition. :)
-
Nice first effort.
Just a couple if tips from another PB coder for this demo though:
You only need to set the transparency once after you load the images.
And you can display the c64 image outside at the end of the scroller display loop rather than display it 25 times per loop.
Keep going though and trying other pieces of code as that's how most of us started. :)
-
Thanks for the feedback :) Ill defiantly make those changes.
Ive started on another demo, but this time i only use in it what i know, so no flashy coding, but it`s fun and nearly all me lol
http://www.dbfinteractive.com/forum/index.php?topic=6481.msg82859#new