Author Topic: New Twister  (Read 31 times)

0 Members and 1 Guest are viewing this topic.

Offline Ampli

  • ZX 81
  • *
  • Posts: 20
  • Karma: 10
    • View Profile
    • StudioRIFF
New Twister
« on: Today at 01:33 AM »
Hello all!
Here is a new pile of shitty code from me.


Code: [Select]
;--------------------------
; MADE WITH PUREBASIC 6.40
; USING UBUNTU 26.04
; YEAR 2026
;--------------------------
; [SPAGHETTICODE]
; CODE=ALDENTE
;--------------------------
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC ""
setenv(name.p-utf8, value.p-utf8, overwrite.l)
EndImport
setenv("GDK_BACKEND", "x11", 1)
CompilerEndIf

InitSprite() : InitKeyboard() : InitSound()

OpenWindow(1, 0, 0, 800, 600, "TWISTER Summer Edition 2026", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1), 0, 0, 800, 600, 0, 0, 0)
SetFrameRate(60)

LoadFont(1, "terminal", 44, #PB_Font_Bold)
LoadFont(2, "terminal", 12, #PB_Font_Bold)

Global Dim text.s(15)
text(0) ="_____._.___ .______   ____   ____     .___ .______  _____._.______  ._______  "
text(1) ="\__ _:|: __|:      \  \   \_/   /     : __|:      \ \__ _:|: __   \ : .___  \ "
text(2) ="  |  :|| : ||       |  \___ ___/      | : ||       |  |  :||  \____|| :   |  |"
text(3) ="  |   ||   ||   |   |    |   |        |   ||   |   |  |   ||   :  \ |     :  |"
text(4) ="  |   ||   ||___|   |    |___|        |   ||___|   |  |   ||   |___\ \_. ___/ "
text(5) ="  |___||___|    |___|                 |___|    |___|  |___||___|       :/     "
text(6) ="                                                                       :      "
text(7) ="                                                                              "
text(8) ="-============================================================================-"
text(9) ="-      THIS IS A SMALL AMIGA INSPIRED INTRO THAT I MADE IN PUREBASIC         -"
text(10)="-    I DIDENT KNOW WHAT TO CODE SO I WENT TO DBF FORUM AND FOUND MY OLD      -"
text(11)="-  TWISTER CODE, I TOOK THE CODE AND STARTED TO WRITE A NEW VERSION OF IT    -"
text(12)="-                                                                            -"
text(13)="-                                             HOPE YOU LIKE IT!     AMPLI-26 -"
text(14)="-============================================================================-"

CreateSprite(1, 3000, 64, #PB_Sprite_AlphaBlending); OVER SIZED I KNOW =P

Global M_PI.f = 3.1415

Global ScrollText$ = "        HELLO ALL! S . W . E . D . E . N SAYS HI TO ALL DBF'ERS, MADE A NEW TWISTER SUMMER EDITION 2026, HOPE YOU LIKE IT....     "
Global ScrollX.f = 800
Global Speed.f = 6
Global aa.f = 0

Global Dim CachedY2.f(800)
Global Dim CachedY3.f(800)
Global Dim CachedS.f(800)

Global x.l, s.f, amp.f, v1.f, v2.f, v3.f, v4.f
Global y1.f, y2.f, y3.f, y4.f
Global color1.l, color3.l, color4.l

Repeat
ExamineKeyboard()
Event = WindowEvent()

If StartDrawing(SpriteOutput(1))
Box(0, 0, 3000, 64, RGB(55, 55, 155))
DrawingFont(FontID(1))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(ScrollX, 0, ScrollText$, RGB(127, 127, 255)) ; Yellow text
TextWidthVal = TextWidth(ScrollText$)
StopDrawing()
EndIf

ScrollX - Speed
If ScrollX < -TextWidthVal
ScrollX = 800
EndIf

aa + 0.05

ClearScreen(RGB(135, 55, 135))

StartDrawing(ScreenOutput())
For x = 0 To 799
s = Sin(aa + x / 250) * 128
amp = (Cos(x / 250) * (s / 175))

v1 = (aa + amp)
v2 = (aa + amp) + M_PI / 2
v3 = (aa + amp) + M_PI
v4 = (aa + amp) + M_PI + M_PI / 2

y1 = 300 + Cos(v1) * 100
y2 = 300 + Cos(v2) * 100
y3 = 300 + Cos(v3) * 100
y4 = 300 + Cos(v4) * 100

CachedY2(x) = y2
CachedY3(x) = y3
CachedS(x)  = s

color1 = RGB(127,127,255)
color2 = RGB(127,127,255)
color3 = RGB(55, 55, 155)

If y1 < y2
Line(x, y1 + s, 1, y2 - y1, color1)
EndIf
If y3 < y4
Line(x, y3 + s, 1, y4 - y3, color2)
EndIf
If y4 < y1
Line(x, y4 + s, 1, y1 - y4, color3)
EndIf
Next x
StopDrawing()

For x = 0 To 799
y2 = CachedY2(x)
y3 = CachedY3(x)
s  = CachedS(x)
If y2 < y3
SidHojd.f = y3 - y2
If SidHojd > 1
ClipSprite(1, x, 0, 1, 64)
TransformSprite(1, 0, 0,  1, 0,  1, SidHojd,  0, SidHojd)
DisplayTransparentSprite(1, x, y2 + s)
EndIf
EndIf
Next x

Define fontSize.i = 12
Define spacing.i = 5
CreateSprite(2,800,600,#PB_Sprite_AlphaBlending)

StartDrawing(SpriteOutput(2))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(2))

ta.f + 0.072 
For i = 0 To ArraySize(text())
tsin = -Abs(Sin(ta+i/5)*25)
DrawText(12,102+tsin+(i * ( fontSize + spacing )),text(i),#White)
Next

StopDrawing()

TransparentSpriteColor(2,RGB(0,0,0))
SpriteBlendingMode(4,8)
DisplayTransparentSprite(2,0,0)

Delay(1) : FlipBuffers()

Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End