Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
32Bowling For John
#21
If anyone happens to care, I am redoing my site. My links will be empty for a while, so hang on a sec.
Reply
#22
OK, I'm trying a new approach, sprites.

I created a sprite loader and included it before the program. I am completely re-writing the thing from scratch.

But, can I do this easier?
Code:
IF (mx > 100 AND mx < 150) AND (my > 100 AND my < 150) THEN

I don't want to have it that long. How can I combine them?
Reply
#23
Quote:OK, I'm trying a new approach, sprites.

I created a sprite loader and included it before the program. I am completely re-writing the thing from scratch.

But, can I do this easier?
Code:
IF (mx > 100 AND mx < 150) AND (my > 100 AND my < 150) THEN

I don't want to have it that long. How can I combine them?
Code:
If mx+my*MaxX > 100+100*MaxX and mx+my*MaxX < 150+150*MaxX then
Point being: You cant do it shorter
Reply
#24
Oh.

There should be a way similar to LINE or GET, you know:
Code:
IF mx > (x1,y1)-(x2,y2) THEN
But oh well.

The entire size is greatly decreased, but I still am not satisfied. BMP is still too big. How could I make an image, say 320*240 stretch to 640*480? That would reduce resolution, but I feel size is a huge part of this project.
Reply
#25
Instead of get use point to store the image into an array and write a function that passes a pointer to it to draw the image...

I'd write an example of such a function but after learning pointers in C++ I never learned them in FreeBASIC...
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#26
That's kinda what I did,
Code:
'$include:'fbgfx.bi'
DECLARE FUNCTION Font (spritex,spritey,text AS STRING,num AS INTEGER)
DECLARE FUNCTION PlaceSprite (spritex,spritey,sprite AS STRING,mode,alpha_level)

DIM SHARED Aboutbtn     (8780)      AS INTEGER
DIM SHARED ball_roll    (5140)      AS INTEGER
DIM SHARED big_ball     (4100)      AS INTEGER
DIM SHARED Chooseball   (223129)    AS INTEGER
DIM SHARED Font_letter  (12264)     AS INTEGER
DIM SHARED Hiscrbtn     (21392)     AS INTEGER
DIM SHARED Load         (37644)     AS INTEGER
DIM SHARED Mainback     (307204)    AS INTEGER
DIM SHARED Mouse        (1716)      AS INTEGER
DIM SHARED Menubuttons  (18544)     AS INTEGER
DIM SHARED Optinbtn     (14408)     AS INTEGER
DIM SHARED Pins         (2168)      AS INTEGER
DIM SHARED Radiumv      (70744)     AS INTEGER
DIM SHARED Startbtn     (4216)      AS INTEGER
DIM SHARED x            (260)       AS INTEGER
DIM SHARED ball_color

SCREEN 18,16,2,GFX_FULLSCREEN
SCREENSET 1,0
setmouse 320,240,0
SLEEP 1000
OPEN "Data\Text\Highscores.dat" FOR RANDOM AS #1
BLOAD "DATA\Images\Mainmenu.bmp",VARPTR(Mainback(0))
GET (0,0)-(640,480),Mainback(0)

BLOAD "DATA\Images\Font.bmp",0
   l_num = -1
   FOR I = 0 TO 111 STEP 18
      FOR J = 0 TO 107 STEP 16
         l_num = l_num + 1
         GET(J,I)-(J + 15, I + 17),Font_letter(292 * l_num)
      NEXT J
   NEXT I
   CLS
BLOAD "DATA\Images\menu_buttons.bmp", 0
   GET (0,0)-(161,25),  Menubuttons(0)
   GET (0,27)-(112,60), Menubuttons(4216)
   GET (0,62)-(176,95), Menubuttons(8062)
   GET (0,97)-(89,122), Menubuttons(14084)
   GET (0,124)-(63,156),Menubuttons(16200)
   CLS
BLOAD "DATA\Images\ball.bmp",0
   GET (0,0)-(31,31),ball_roll(0)
   GET (0,32)-(31,63),ball_roll(1029)
   GET (0,64)-(31,95),ball_roll(2057)
   GET (0,96)-(31,127),ball_roll(3085)
   GET (32,64)-(63,95),ball_roll(4112)
   GET (32,0)-(96,64),big_ball(0)
   CLS
BLOAD "DATA\Images\mouse.bmp",0
   GET(0,0)-(16,24),Mouse(0)
   GET(0,25)-(18,49),Mouse(454)
   GET(17,0)-(33,24),Mouse(908)
   GET(18,25)-(33,49),Mouse(1312)
   CLS
BLOAD "DATA\Images\Radiumv.bmp",0
   GET (0,0)-(539,130),Radiumv(0)
   CLS
BLOAD "DATA\Images\load.bmp",0
   GET (256,0)-(512,48),Load(0)
   GET (0,0)-(255,48),Load(12292)
   GET (0,49)-(256,99),Load(25352)
   CLS
BLOAD "DATA\Images\Pins.bmp"
   GET (0,0)-(19,58),Pins(0)
   GET (21,0)-(40,38),Pins(1160)
   GET (21,40)-(30,58),Pins(1890)
   GET (31,46)-(40,58),Pins(2056)
BLOAD "DATA\Images\Chooseball.bmp"
   GET (0,0)-(625,357),Chooseball(0)
CLS

FUNCTION Font (spritex,spritey,text AS STRING,num AS INTEGER)
   l_next = 0
   IF num > -1 THEN text = STR$(num)
   text = UCASE$(text)
   FOR a = 1 TO LEN(text)
      IF MID$(text,a,1) = " " THEN l_num = -1
      IF MID$(text,a,1) = "A" THEN l_num = 0
      IF MID$(text,a,1) = "B" THEN l_num = 1
      IF MID$(text,a,1) = "C" THEN l_num = 2
      IF MID$(text,a,1) = "D" THEN l_num = 3
      IF MID$(text,a,1) = "E" THEN l_num = 4
      IF MID$(text,a,1) = "F" THEN l_num = 5
      IF MID$(text,a,1) = "G" THEN l_num = 6
      IF MID$(text,a,1) = "H" THEN l_num = 7
      IF MID$(text,a,1) = "I" THEN l_num = 8
      IF MID$(text,a,1) = "J" THEN l_num = 9
      IF MID$(text,a,1) = "K" THEN l_num = 10
      IF MID$(text,a,1) = "L" THEN l_num = 11
      IF MID$(text,a,1) = "M" THEN l_num = 12
      IF MID$(text,a,1) = "N" THEN l_num = 13
      IF MID$(text,a,1) = "O" THEN l_num = 14
      IF MID$(text,a,1) = "P" THEN l_num = 15
      IF MID$(text,a,1) = "Q" THEN l_num = 16
      IF MID$(text,a,1) = "R" THEN l_num = 17
      IF MID$(text,a,1) = "S" THEN l_num = 18
      IF MID$(text,a,1) = "T" THEN l_num = 19
      IF MID$(text,a,1) = "U" THEN l_num = 20
      IF MID$(text,a,1) = "V" THEN l_num = 21
      IF MID$(text,a,1) = "W" THEN l_num = 22
      IF MID$(text,a,1) = "X" THEN l_num = 23
      IF MID$(text,a,1) = "Y" THEN l_num = 24
      IF MID$(text,a,1) = "Z" THEN l_num = 25
      IF MID$(text,a,1) = "0" THEN l_num = 26
      IF MID$(text,a,1) = "1" THEN l_num = 27
      IF MID$(text,a,1) = "2" THEN l_num = 28
      IF MID$(text,a,1) = "3" THEN l_num = 29
      IF MID$(text,a,1) = "4" THEN l_num = 30
      IF MID$(text,a,1) = "5" THEN l_num = 31
      IF MID$(text,a,1) = "6" THEN l_num = 32
      IF MID$(text,a,1) = "7" THEN l_num = 33
      IF MID$(text,a,1) = "8" THEN l_num = 34
      IF MID$(text,a,1) = "9" THEN l_num = 35
      IF MID$(text,a,1) = "!" THEN l_num = 36
      IF MID$(text,a,1) = "?" THEN l_num = 37
      IF MID$(text,a,1) = "." THEN l_num = 38
      IF MID$(text,a,1) = "@" THEN l_num = 39
      IF MID$(text,a,1) = "," THEN l_num = 40
      IF MID$(text,a,1) = "_" THEN l_num = 41
      IF l_num >= 0 THEN PUT(spritex + l_next,spritey),Font_letter(292 * l_num),TRANS
      FOR I = 27 TO 35
         IF l_num = I THEN l_next = l_next - 3
      NEXT I
      IF l_num = 8 OR l_num = 9 OR l_num = 18 THEN l_next = l_next - 4
      l_next = l_next + 14
   NEXT
END FUNCTION

FUNCTION PlaceSprite (spritex,spritey,sprite AS STRING,mode,alpha_level)

   sprite$ = LCASE$(sprite$)
   IF mode = 0 THEN 'PSET Only
      IF sprite$ = "Chooseball screen" THEN PUT(spritex,spritey),Chooseball(0)
   END IF
  
   IF mode = 1 THEN  'Trans Only
      IF sprite$ = "big ball" THEN
         PUT(spritex,spritey),big_ball(0),TRANS
         PAINT(spritex + 32,spritey + 32),ball_color,&hC0C0C0
      END IF
      IF sprite$ = "startbtn" THEN PUT(spritex,spritey),Menubuttons(0),TRANS
      IF sprite$ = "optinbtn" THEN PUT(spritex,spritey),Menubuttons(4216),TRANS
      IF sprite$ = "hiscrbtn" THEN PUT(spritex,spritey),Menubuttons(8062),TRANS
      IF sprite$ = "aboutbtn" THEN PUT(spritex,spritey),Menubuttons(14084), TRANS
      IF sprite$ = "quitsbtn" THEN PUT(spritex,spritey),Menubuttons(16200), TRANS
      
      IF sprite$ = "load 1" THEN PUT(spritex,spritey),Load(0),TRANS
      IF sprite$ = "load 2" THEN PUT(spritex,spritey),Load(12292),TRANS
      IF sprite$ = "load 3" THEN PUT(spritex,spritey),Load(25352),TRANS
   END IF
  
   IF mode = 2 THEN  'Alpha Only
      IF sprite$ = "radiumv" THEN PUT(spritex,spritey),Radiumv(0),ALPHA,alpha_level
      IF sprite$ = "mainmenu" THEN PUT(0,0),Mainback(0),ALPHA,alpha_level
   END IF

   IF mode = 3 THEN  'Trans with Alpha Shadow
      IF MID$(sprite$,1,8) = "ballroll" THEN
         IF MID$(sprite$,10,1) = "1" THEN PUT(spritex,spritey),ball_roll(0),TRANS
         IF MID$(sprite$,10,1) = "2" THEN PUT(spritex,spritey),ball_roll(1029),TRANS
         IF MID$(sprite$,10,1) = "3" THEN PUT(spritex,spritey),ball_roll(2057),TRANS
         PAINT(spritex + 16,spritey + 16),ball_color,&hC0C0C0
         PUT(spritex,spritey),ball_roll(4112),ALPHA,128
      END IF
      
      IF MID$(sprite$,1,5) = "mouse" THEN
         IF MID$(sprite$,7,1) = "1" THEN
            PUT(spritex,spritey),Mouse(908),ALPHA,180
            PUT(spritex,spritey),Mouse(0),TRANS
         END IF
         IF MID$(sprite$,7,1) = "2" THEN
            PUT(spritex+3,spritey),Mouse(1312),ALPHA,180
            PUT(spritex,spritey),Mouse(454),TRANS
         END IF
      END IF
      
      IF MID$(sprite$,1,3) = "pin" THEN
         IF MID$(sprite$,5) = "1" THEN
            PUT(spritex,spritey),PINS(0),TRANS
            PUT(spritex+16,spritey+40),PINS(1890),ALPHA,128
         END IF
         IF MID$(sprite$,5) = "2" THEN
            PUT(spritex,spritey),PINS(1160),TRANS
            PUT(spritex+16,spritey+26),PINS(2056),ALPHA,128
         END IF
      END IF
   END IF
  
END FUNCTION

Part one is text font and 2 is sprites. I should convert to point, though.
Reply
#27
You can make it a bit shorter and faster. In your text printing routine you are calculating Mid$(text, a, 1) a lot of times - you can precalculate this. Plus all those lines can be shortened::

Replace this:

Code:
IF MID$(text,a,1) = "A" THEN l_num = 0
      IF MID$(text,a,1) = "B" THEN l_num = 1
      IF MID$(text,a,1) = "C" THEN l_num = 2
      IF MID$(text,a,1) = "D" THEN l_num = 3
      IF MID$(text,a,1) = "E" THEN l_num = 4
      IF MID$(text,a,1) = "F" THEN l_num = 5
      IF MID$(text,a,1) = "G" THEN l_num = 6
      IF MID$(text,a,1) = "H" THEN l_num = 7
      IF MID$(text,a,1) = "I" THEN l_num = 8
      IF MID$(text,a,1) = "J" THEN l_num = 9
      IF MID$(text,a,1) = "K" THEN l_num = 10
      IF MID$(text,a,1) = "L" THEN l_num = 11
      IF MID$(text,a,1) = "M" THEN l_num = 12
      IF MID$(text,a,1) = "N" THEN l_num = 13
      IF MID$(text,a,1) = "O" THEN l_num = 14
      IF MID$(text,a,1) = "P" THEN l_num = 15
      IF MID$(text,a,1) = "Q" THEN l_num = 16
      IF MID$(text,a,1) = "R" THEN l_num = 17
      IF MID$(text,a,1) = "S" THEN l_num = 18
      IF MID$(text,a,1) = "T" THEN l_num = 19
      IF MID$(text,a,1) = "U" THEN l_num = 20
      IF MID$(text,a,1) = "V" THEN l_num = 21
      IF MID$(text,a,1) = "W" THEN l_num = 22
      IF MID$(text,a,1) = "X" THEN l_num = 23
      IF MID$(text,a,1) = "Y" THEN l_num = 24
      IF MID$(text,a,1) = "Z" THEN l_num = 25
      IF MID$(text,a,1) = "0" THEN l_num = 26
      IF MID$(text,a,1) = "1" THEN l_num = 27
      IF MID$(text,a,1) = "2" THEN l_num = 28
      IF MID$(text,a,1) = "3" THEN l_num = 29
      IF MID$(text,a,1) = "4" THEN l_num = 30
      IF MID$(text,a,1) = "5" THEN l_num = 31
      IF MID$(text,a,1) = "6" THEN l_num = 32
      IF MID$(text,a,1) = "7" THEN l_num = 33
      IF MID$(text,a,1) = "8" THEN l_num = 34
      IF MID$(text,a,1) = "9" THEN l_num = 35
      IF MID$(text,a,1) = "!" THEN l_num = 36
      IF MID$(text,a,1) = "?" THEN l_num = 37
      IF MID$(text,a,1) = "." THEN l_num = 38
      IF MID$(text,a,1) = "@" THEN l_num = 39
      IF MID$(text,a,1) = "," THEN l_num = 40
      IF MID$(text,a,1) = "_" THEN l_num = 41

With:

Code:
m$ = Mid$ (text, a, 1)
If m$ >= "A" And m$ <= "Z" Then
    l_num = Asc (m$) - Asc ("A")
Else If m$ >= "0" And m$ <= "9" Then
    l_num = 26 + Val (m$)
Else If m$ = "!" Then
    l_num = 36
Else If m$ = "?" Then
    l_num = 37
Else If m$ = "." Then
    l_num = 38
Else If m$ = "@" Then
    l_num = 39
Else If m$ = "," Then
    l_num = 40
Else If m$ = "_" Then
    l_num = 41
End If

---

Though it could have been shortened significally using some leet function shredding - nice one-liner, which replace all those IFs:

Code:
l_num = Instr ("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?.@,_", Mid$ (text, a, 1)) - 1

What the above line does is:

1.- get the current character with Mid$ (text, a, 1)
2.- look for it in the "ABCDEF... string. Instr will return a number with its position within the string or 0 if it is not found.
3.- We substract 1.

That way if Mid$ (text, a, 1) = "B", Instr returns "2", we substract 1 and we get l_num = 1, for example. Or if Mid$ (text, a, 1) = " " ,Instr returns "0", we substract 1 and we get l_num = -1.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#28
Wow, that one line replaces everything!? Thanks! Big Grin Big Grin Big Grin
Reply
#29
Alright, I've been working on this for a while, and I came to a tick.

When aiming the ball after selecting position, the line to direct the ball goes straight across. I want it to curve, maybe someone could help me with the trig? Move around with mouse. Just generic points, I can change them later.

[Image: bowlingaim.gif]
Reply
#30
I could help with trig. What is it you needed?
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)