News:

Function Finder  Find all the functions within source code files

Main Menu

hard codin all the way!

Started by RaverDave, January 23, 2006, 08:36:26 AM

Previous topic - Next topic

RaverDave

Just decided to code a fruit machine I have on some dedicated tv console I have, the pic shows it in action on the tv, the code is what I have so far! pretty similar, challenge is not to use one prefab'd file..its code all the way!!

PlayBASIC Code: [Select]
; PROJECT : fruit
; AUTHOR : Dave
; CREATED : 22/01/2006
; EDITED : 23/01/2006
; ---------------------------------------------------------------------
OpenScreen 320,240,32,2

SetFPS 60
ScreenVsync On
Mouse Off
Global credits
Global divx#=16
Global divy#=16

Type fruit
X,Y,SizeX,SizeY
EndType
Dim fruits(9) As fruit

Repeat
makegfx()
credits=100
Repeat

DrawImage 1,0,0,True
Sync
Until credits=0
Until v=100

Function makegfx()
;********** Create backdrop ************
CreateImage 1,320,240
;main area
RenderToImage 1
BoxC 0,0,320,240,1,RGB(255, 128, 0)
; centre yellow
BoxC divx#*5-10,divy#*5,divx#*12,divy#*11,True,RGB(255, 255, 0)
; red centre
BoxC divx#*5.5-10,divy#*5.5,divx#*11.5,divy#*10.5,True,RGB (255,0,0)

;draw the reels
For n=1 To 3
BoxC divx#*6+space,divy#*6,divx#*7+3+space,divy#*10,True,RGB(0,0,0)
BoxC divx#*6+space,divy#*10,divx#*7+4+space,divy#*10+1,True,RGB(255,255,255)
BoxC divx#*7+3+space2,divy#*6,divx#*7+4+space2,divy#*10,True,RGB(255,255,255)
space=space+25
space2=space2+25
Next


BoxC 0,divy#*12,640,divy#*12+1,True,RGB(1,1,1)
;draw the yellowy lines near the bottom
For n=2 To 10 Step 2
BoxC 0,divy#*12+n,640,divy#*12+n+1,True,RGB(255, 255, 0)
Next
;draw the couple of stray lines near bottom
BoxC 0,divy#*12+13,640,divy#*12+14,True,RGB(255, 255, 0)
BoxC 0,divy#*12+16,640,divy#*12+17,True,RGB(255, 255, 0)
BoxC 0,divy#*12+19,640,divy#*12+20,True,RGB(1,1,1)
BoxC 0,divy#*3+19,640,divy#*3+21,True,RGB(1,1,1)

;************* draw the button effigys over the lines
For n=1 To 3
Ink RGB(1,1,1)
Circle divx#+add1,divy#*12+7,5,True
Ink RGB(255,0,255)
Circle divx#+add1,divy#*12+7,4,True
add1=add1+18

Next
;***************** the middle lot of buttons
For n=1 To 5
Ink RGB(1,1,1)
Circle divx#*8+add2,divy#*12+7,5,True
Ink RGB(255, 0, 255)
Circle divx#*8+add2,divy#*12+7,4,True
add2=add2+9
Next
;*******************************************
;********************* A few at the End
For n=1 To 3
Ink RGB(1,1,1)
Circle divx#*16+add3,divy#*12+7,5,True
Ink RGB(255,0,255)
Circle divx#*16+add3,divy#*12+7,4,True
add3=add3+18
Next
;*********************************************************

Ink RGB(255,255,255)

;****************** draw the Bet Box
s$="BET"
BoxC divx#*14-3,divy#*5-2,divx#*19-2,divy#*6-1,True,RGB(1,1,1)
BoxC divx#*13-4,divy#*5-4,divx#*19,divy#*6,False,RGB(1,1,1)
Text divx#*14-2,divy#*5,s$

;***************************************************************
;
;******************** draw the win box
s$="WIN"
BoxC divx#*14-3,divy#*6+4,divx#*19-2,divy#*7+5,True,RGB(1,1,1)
BoxC divx#*13-4,divy#*6+2,divx#*19,divy#*7+6,False,RGB(1,1,1)
Text divx#*14-2,divy#*6+7,s$
;***********************************

;Rem Lets not be that hardcore and copy some!! :D
GetImage 2,0,divy#*12,640,divy#*12+18
DrawImage 2,0,divy#*3,True


RenderToScreen
;***************************************

EndFunction

Function dump()

EndFunction






P.S a tip, notice the function dump?? I always do this,its a good idea,I put chunks of code in there that I am going to modify, so i can revert back if things go wrong! Of course it never gets called! :D:D

RaverDave

This is a pic with flash on camera! wooppee you can see all the mess!! As you can also gather the walls are plastered with posters,mainly spiderman!!


Anyhow this should be a fun project and just a small side thing while I take a break from the bat and ball code!

Ian Price

That should be a doddle for you RaverDave. Creating images/sprites from data just takes a bit of time entering, but other than that should be pretty simple.

I created several Div games in code only (excluding sfx) - Hangman, Defender and Ballonacy were all code only originally.

Anyway, will this pay out real fivers if I get 3 SEVENs? :P

Nice to see something different (I haven't seen a fruit machine game in years)

Good luck. :)
I came. I saw. I played some Nintendo.

RaverDave

Yeh, I thought it wuld be nice to do one, I last coded fruit machine code in div actually, it was just a demo,never got finished! I should finish this though!

RaverDave

#4
ahahhahaaaaa!! Here's my first fruit,meant to be a melon..errrr!!


Graph paper anyone?? :F:F:F



PlayBASIC Code: [Select]
; PROJECT : fruit
; AUTHOR : Dave
; CREATED : 22/01/2006
; EDITED : 24/01/2006
; ---------------------------------------------------------------------
OpenScreen 320,240,32,2

SetFPS 60
ScreenVsync On
Mouse Off
Global credits
Global divx#=16
Global divy#=16

Type fruit
X,Y,SizeX,SizeY
EndType
Dim fruits(9) As fruit
makegfx()
makefruits()
Repeat

credits=100
Repeat

DrawImage 1,0,0,True
DrawImage 20,divx#*6+2,divy#*6+1,True
Sync
Until credits=0
Until v=100

Function makegfx()

;********** Create backdrop ************
CreateImage 1,320,240
;main area
RenderToImage 1
BoxC 0,0,320,240,1,RGB(255, 128, 0)
; centre yellow
BoxC divx#*5-10,divy#*5,divx#*12,divy#*11,True,RGB(255, 255, 0)
; red centre
BoxC divx#*5.5-10,divy#*5.5,divx#*11.5,divy#*10.5,True,RGB (255,0,0)

;draw the reels
For n=1 To 3
BoxC divx#*6+space,divy#*6,divx#*7+3+space,divy#*10,True,RGB(0,0,0)
BoxC divx#*6+space,divy#*10,divx#*7+4+space,divy#*10+1,True,RGB(255,255,255)
BoxC divx#*7+3+space2,divy#*6,divx#*7+4+space2,divy#*10,True,RGB(255,255,255)
space=space+25
space2=space2+25
Next


BoxC 0,divy#*12,640,divy#*12+1,True,RGB(1,1,1)
;draw the yellowy lines near the bottom
For n=2 To 10 Step 2
BoxC 0,divy#*12+n,640,divy#*12+n+1,True,RGB(255, 255, 0)
Next
;draw the couple of stray lines near bottom
BoxC 0,divy#*12+13,640,divy#*12+14,True,RGB(255, 255, 0)
BoxC 0,divy#*12+16,640,divy#*12+17,True,RGB(255, 255, 0)
BoxC 0,divy#*12+19,640,divy#*12+20,True,RGB(1,1,1)
BoxC 0,divy#*3+19,640,divy#*3+21,True,RGB(1,1,1)

;************* draw the button effigys over the lines
For n=1 To 3
Ink RGB(1,1,1)
Circle divx#+add1,divy#*12+7,5,True
Ink RGB(255,0,255)
Circle divx#+add1,divy#*12+7,4,True
add1=add1+18

Next
;***************** the middle lot of buttons
For n=1 To 5
Ink RGB(1,1,1)
Circle divx#*8+add2,divy#*12+7,5,True
Ink RGB(255, 0, 255)
Circle divx#*8+add2,divy#*12+7,4,True
add2=add2+9
Next
;*******************************************
;********************* A few at the End
For n=1 To 3
Ink RGB(1,1,1)
Circle divx#*16+add3,divy#*12+7,5,True
Ink RGB(255,0,255)
Circle divx#*16+add3,divy#*12+7,4,True
add3=add3+18
Next
;*********************************************************

Ink RGB(255,255,255)

;****************** draw the Bet Box
s$="BET"
BoxC divx#*14-3,divy#*5-2,divx#*19-2,divy#*6-1,True,RGB(1,1,1)
BoxC divx#*13-4,divy#*5-4,divx#*19,divy#*6,False,RGB(1,1,1)
Text divx#*14-2,divy#*5,s$

;***************************************************************
;
;******************** draw the win box
s$="WIN"
BoxC divx#*14-3,divy#*6+4,divx#*19-2,divy#*7+5,True,RGB(1,1,1)
BoxC divx#*13-4,divy#*6+2,divx#*19,divy#*7+6,False,RGB(1,1,1)
Text divx#*14-2,divy#*6+7,s$
;***********************************

;Rem Lets not be that hardcore and copy some!! :D
GetImage 2,0,divy#*12,640,divy#*12+18
DrawImage 2,0,divy#*3,True


RenderToScreen
;***************************************

EndFunction

Function makefruits()
CreateImage 20,16,16
RenderToImage 20
For y=0 To 16
For x=0 To 16
p=ReadData()
If p=1
DotC x,y,RGB(255, 0, 0)
EndIf
If p=2
DotC x,y,RGB(0, 128, 0)
EndIf

If p=3
DotC x,y,RGB(0, 255, 64)
EndIf



If p=9
DotC x,y,RGB(1,1,1)
EndIf


Next
Next
RenderToScreen
EndFunction


Login required to view complete source code



RaverDave

Oh my!! its improving!
I found out that actually the image created needed to be a pixel bigger either way!dah

RaverDave

#6
PERFECT!!

Ok it took me an hour!
Man where is that graph paper?


PlayBASIC Code: [Select]
Function makefruits()
CreateImage 20,17,17
RenderToImage 20
For y=0 To 16
For x=0 To 16
p=ReadData()
If p=1
DotC x,y,RGB(255, 0, 0)
EndIf
If p=2
DotC x,y,RGB(0, 128, 0)
EndIf
If p=3
DotC x,y,RGB(0, 255, 64)
EndIf
If p=9
DotC x,y,RGB(1,1,1)
EndIf
Next
Next
RenderToScreen
EndFunction
;

Data 0,0,0,0,3,2,2,2,2,2,2,0,0,0,0,0,0
Data 0,0,0,3,1,2,2,2,2,2,2,2,2,0,0,0,0
Data 0,0,3,1,1,1,3,3,3,3,3,2,2,2,0,0,0
Data 0,3,1,1,1,9,1,3,3,3,3,3,3,3,2,0,0
Data 3,1,9,1,1,1,9,1,2,2,2,3,3,3,3,2,0
Data 3,1,1,9,1,1,1,1,2,2,2,2,2,2,3,3,0
Data 3,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2
Data 3,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,2
Data 3,1,1,1,9,1,1,1,3,3,3,3,3,3,3,3,2
Data 3,1,1,1,1,9,1,1,2,2,2,2,2,2,2,2,2
Data 3,1,1,9,1,1,1,1,2,2,2,2,2,2,2,2,0
Data 3,9,1,1,1,1,1,2,2,2,2,3,3,3,3,3,0
Data 3,1,9,1,1,1,1,3,3,3,3,3,3,3,3,2,0
Data 3,1,1,1,9,1,3,3,3,3,3,2,2,2,0,0,0
Data 0,3,1,1,1,2,2,2,2,2,2,2,0,0,0,0,0
Data 0,0,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0




Ian Price

A mouth-watering water melon!

Keep it up :)
I came. I saw. I played some Nintendo.

RaverDave

no more code spamming now,just periodic screenies, here's a few more fruits, ready to be spung also!