Qbasicnews.com
May 23, 2019, 04:28:14 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2] 3
  Print  
Author Topic: 32Bowling For John  (Read 14829 times)
j2krei08
Guru
**
Posts: 284



WWW
« Reply #15 on: December 15, 2005, 03:26:02 PM »

So, can you help with the flashing or timing?
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #16 on: December 15, 2005, 08:54:58 PM »

j2krei, not to stray from the topic or anything...but your avatar scares the hell outta me.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
jsmith71
Been there, done that
*****
Posts: 1004


« Reply #17 on: December 15, 2005, 08:55:46 PM »

Quote from: "Zack"
j2krei, not to stray from the topic or anything...but your avatar scares the hell outta me.

Pink Floyd man, Pink Floyd! :wink:
Logged
j2krei08
Guru
**
Posts: 284



WWW
« Reply #18 on: December 16, 2005, 01:47:38 PM »

Yes, my avatar is wierd, and it took me an hour to get it just right (ripped straight from the movie)

Anywho, I changed a few things myself and I will replace the file online by Monday.

Still, can someone help me with the scoring process?  I want it like regular, because right now it just adds 30 for strikes and 20 for spares.
Logged
j2krei08
Guru
**
Posts: 284



WWW
« Reply #19 on: December 21, 2005, 02:01:34 PM »

I updated the file.

I fixed some things and made some things completely different.

Download it and see (I need testers badly)
Logged
j2krei08
Guru
**
Posts: 284



WWW
« Reply #20 on: January 10, 2006, 02:47:49 PM »

If anyone happens to care, I am redoing my site.  My links will be empty for a while, so hang on a sec.
Logged
j2krei08
Guru
**
Posts: 284



WWW
« Reply #21 on: January 31, 2006, 05:12:56 PM »

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?
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #22 on: February 01, 2006, 05:01:47 AM »

Quote from: "j2krei08"
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
Logged
j2krei08
Guru
**
Posts: 284



WWW
« Reply #23 on: February 02, 2006, 06:56:00 PM »

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.
Logged
TheDarkJay
I hold this place together
*****
Posts: 913



WWW
« Reply #24 on: February 03, 2006, 01:42:48 PM »

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...
Logged

url=http://www.sloganizer.net/en/][/url]
j2krei08
Guru
**
Posts: 284



WWW
« Reply #25 on: February 13, 2006, 03:14:33 PM »

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.
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #26 on: February 14, 2006, 07:48:49 AM »

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.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
j2krei08
Guru
**
Posts: 284



WWW
« Reply #27 on: February 14, 2006, 12:05:40 PM »

Wow, that one line replaces everything!?  Thanks! Cheesy  Cheesy  Cheesy
Logged
j2krei08
Guru
**
Posts: 284



WWW
« Reply #28 on: March 27, 2006, 06:59:21 PM »

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.

Logged
Torahteen
Ancient Guru
****
Posts: 744



« Reply #29 on: March 27, 2006, 07:09:28 PM »

I could help with trig. What is it you needed?
Logged

quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!