Adam1213 Posted December 25, 2006 Share Posted December 25, 2006 game.zipThe game (shooting only works for 90° currenlty) It also does not have a proper name and is still being refered to by its code name 'Game' gafrost's scrolling GUI has allowed me to move the background without having white flashes. IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 Link to comment Share on other sites More sharing options...
Adam1213 Posted November 19, 2008 Author Share Posted November 19, 2008 Due to changes to autoit the code stopped working so I have made a few modifications to game.au3 (to run this extract the zip file and replace game.au3 with this code) expandcollapse popup#include <GUIConstants.au3> #Include <GuiStatusBar.au3> #include <GUIScrollBars.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <ScrollBarConstants.au3> #include <GuiScrollBars.au3> ;_____________________ SETTINGS ______________________________ global $players=2 global $multiply=5 ; Movement speed global $jump=60 global $ground=10 global $gravity=1 global $jet_depleat=1 global $jet_refill=0.4 global $jet_fuel=200 global $max_bullets=4 global $bullet_speed=2 global $start_jet=$jet_fuel ;_____________________________________________________________ global $me=0 global $SHOWSCROLLBARS=0 Global $m_width =@DesktopWidth, $m_height = 740 global $player_img_height=67 global $player_img_width=44 global $height=$m_height-$player_img_height global $width=$m_width-90 global $MAP_width=2000 global $scroll_width=$MAP_width/1.87 global $MAP_x=0 global $display[$players] global $pos[$players][2] global $pd[$players][1] ;____________________KEYS_________________________________________ global $d[1][4] $d[0][0] = 25; left $d[0][1] = 27;right $d[0][2] = 26; up $d[0][3] = 28; down Opt("GUIOnEventMode", 1) ;_________________________________________________________________________________ $dll = DllOpen("user32.dll") ; no child gui or no controls exceeding the width/height of the window ;~ Global $c_width = 0, $c_height = 0, $c_left = 0, $c_top = 0 Local $nFileMenu, $nExititem, $GUIMsg, $h_cGUI, $h_cGUI2 Local $listview, $button ;___________________________________________________________________________________________________ ;_____________________________________ GUI __________________________________________________________ ;___________________________________________________________________________________________________ ;GUIRegisterMsg($WM_CREATE, "MY_WM_CREATE") if $SHOWSCROLLBARS then GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE"); SCROLLBARS!!!! (SHOWTHEM)!!!!!!!!!!!!!!!!!!!! global $hGUI = GUICreate('Game', $m_width, $m_height, -1, -1, BitOR($WS_MAXIMIZE, $WS_POPUPWINDOW, $WS_SYSMENU));, $WS_VSCROLL, $WS_HSCROLL GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') GUISetCursor(16,1,$hGUI); No cursor GUISetBkColor(0x88AABB) ;$nFileMenu = GUICtrlCreateMenu("File") ;$nExititem = GUICtrlCreateMenuitem("Exit", $nFileMenu) GUICtrlCreatePic('background.jpg', 0,0, $MAP_width, $m_height+10); !!!!!!!!! for $i=0 to $players-1 $pd[$i]['f']=$start_jet $pos[$i][0]=30 $pos[$i][1]=$ground $display[$i]=GUICtrlCreatePic('merlin.gif', $pos[$i][0], $height-$pos[$i][1], $player_img_width, $player_img_height);@Systemdir & "\oobe\images\ next global $bullets[$players][$max_bullets][5] for $plr=0 to $players-1 for $i=0 to $max_bullets-1 $bullets[$plr][$i][0]=GUICtrlCreatePic('bullet.gif', -20, -20, 20, 20) $bullets[$plr][$i][1]=-20; x $bullets[$plr][$i][2]=-20;y $bullets[$plr][$i][3]=0; Gradient $bullets[$plr][$i][4]=0 next next GUISetState() ;______________________________CURSOR GUI __________________________________________________________________ $cursor=GUICreate("", 20, 20, 50, 90,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hGUI) GUISetCursor(16,1,$cursor) GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, 'onclick',$cursor ) GUICtrlCreatePic('cursor.gif', 0, 0, 20, 20) GUISetState(@SW_SHOW, $cursor) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') ;___________________________ STATUS BAR GUI ____________________________________________________________________ $gui_status=GUICreate("", $m_width, 20, 0, $m_height+10, BitOR($WS_SYSMENU,$WS_POPUPWINDOW,$WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) Local $a_PartsRightEdge[6] = [100, 200, 300, 400, 500, 700] Local $a_PartsText[6] = ['Health: 100%','Jet: 100%', 'Amo: 100%', 'Player 1:', 'Map:'] Global $StatusBar1 =_GUICtrlStatusBar_Create ($gui_status, $a_PartsRightEdge, $a_PartsText) _GuiCtrlStatusBar_SetIcon ($StatusBar1, 1, "shell32.dll", 168) _GuiCtrlStatusBar_SetIcon ($StatusBar1, 0, "shell32.dll", 21) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') GUISetState() ;___________________________________________________________________________________________________ __________ GUISwitch($hGUI) _GUIScrollBars_SetScrollRange ($hGUI, $SB_HORZ, 0, $scroll_width) while 1 move() cursor() bullets() sleep(1) wend exit ;================================ MOVE ======================================================================== func move() $x=$pos[$me][0] $y=$pos[$me][1] ;______________________ LEFT _________________________________________ If _IsPressed ($d[$me][0], $dll) then if ($pos[$me][0]>=$MAP_x)=0 AND $MAP_x>0 then movemap(-1) else if $pos[$me][0]>0 then $pos[$me][0]-=$multiply endif endif ;______________________ RIGHT ________________________________________ If _IsPressed ($d[$me][1], $dll) then if ($pos[$me][0]<$MAP_x+$width-$player_img_width)=0 AND $MAP_x<$scroll_width-$width then movemap(1) else if $pos[$me][0]<$scroll_width+$player_img_width then $pos[$me][0]+=$multiply endif endif ;______________________ UP (JUMP) _______________________________________________________________ If _IsPressed ($d[$me][2], $dll) AND $pos[$me][1]<=$ground then $pos[$me][1]+=$jump ;______________________ FLY _____________________________________________________________________ $i=GUIGetCursorInfo ($hGUI) $temp_pdf=$pd[$i]['f'] if $i[3] AND $pd[$i]['f']>=1 then $pos[$me][1]+=2 $pd[$i]['f']-=$jet_depleat else if $pd[$i]['f']<$jet_fuel then $pd[$i]['f']+=$jet_refill endif endif ;____________________ Come down _____________________________________________ for $t=0 to $players-1 if $pos[$t][1]>$ground then $pos[$t][1]-=$gravity endif next if $pd[$me]['f']<>$temp_pdf then _GuiCtrlStatusBar_SetText ($StatusBar1, 'Jet: '&Round($pd[$me]['f']/$jet_fuel*100)&'%', 1) endif ;_______________________________________________________________________ if $pos[$me][0]<>$x OR $pos[$me][1]<>$y then moveplayer($me) endif EndFunc ;=========================================== MOVE PLAYER ====================================== func moveplayer($plr) GUICtrlSetPos($display[$me], $pos[$me][0]-$MAP_x, $height-$pos[$me][1]) _GuiCtrlStatusBar_SetText ($StatusBar1, 'Player 1: '&$pos[$me][0]&'x'&$pos[$me][1], 3) endfunc func movemap($ammount) $MAP_x+=$ammount*$multiply _SetScrollPos ($hGUI, $SB_HORZ, $MAP_x) _GuiCtrlStatusBar_SetText ($StatusBar1, 'Map: '&$MAP_x, 4) endfunc ;========================= CURSOR =============================================================== func cursor() $c=MouseGetPos() WinMove($cursor,"",$c[0]-10, $c[1]-10) endfunc ;=========================== BULLETS============================================================== func bullets() for $plr=0 to $players-1 for $i=0 to $max_bullets-1 if $bullets[$plr][$i][1]>-20 then $bullets[$plr][$i][1]+=$bullets[$plr][$i][3] $bullets[$plr][$i][2]+=$bullets[$plr][$i][4] if $bullets[$plr][$i][1]>$MAP_width OR $bullets[$plr][$i][1]<0 _ OR $bullets[$plr][$i][0]>$height OR $bullets[$plr][$i][1]<0 then $bullets[$plr][$i][1]=-20 else GUICtrlSetPos($bullets[$plr][$i][0], $bullets[$plr][$i][1]-$MAP_x, $height-$bullets[$plr][$i][2]) endif endif next next endfunc ;================== ON FIRE (click) ============================================================== func onclick() ;_____________ LOCATE BULLET TO USE ________________________________ local $bn=-1 for $i=0 to $max_bullets-1 if $bullets[$me][$i][1]=-20 then $bn=$i exitloop endif next if $bn=-1 then return ;___________________ DIRECTION _____________________________________ $start_x=$pos[$me][0]+$player_img_width/2 $start_y=$pos[$me][1]-$player_img_height/2 $cursorinfo=GUIGetCursorInfo($hGUI) $xdist=$cursorinfo[0]-$pos[$me][0]; cursor- start_pos $ydist=($start_y+$m_height)-$cursorinfo[1]; (startpos) - cursor $grad=$ydist/$xdist $bullets[$me][$bn][1]=$start_x $bullets[$me][$bn][2]=$start_y $bullets[$me][$bn][3]=$bullet_speed/Sqrt(expo($grad,2)+1) $bullets[$me][$bn][4]=$grad*($bullet_speed/Sqrt(expo($grad,2)+1)) ;_GuiCtrlStatusBar_SetText ($StatusBar1, 'Bullet: '&$dist_x&'x'&$dist_y&' '&round($grad,2)&'x'&round($grado,2), 5) ;fire! endfunc func expo($n, $exp) $r=$n for $i=1 to ($exp-1) $r*=$n next return $r endfunc ;============================================= func quit() exit $crash=$problem+1 endfunc IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 Link to comment Share on other sites More sharing options...
ludocus Posted November 19, 2008 Share Posted November 19, 2008 yeh it works.. altough very buggy and strange.. - (negative): 1) I dont know what the point is, what do I have to do? 2) you say it doesn't flash.. well at my computer it flashes! 3) The gui is totally missplaced.. It is specially made for your computer... 4) the bullet moves to slow 5) the background is ugly.. + (positive): 1) The jet and jump funtions work real smooth and cool.. Link to comment Share on other sites More sharing options...
Adam1213 Posted November 23, 2008 Author Share Posted November 23, 2008 I never really finished coding this so its missing many features - the basic idea was to scroll a gui have jump and fire (in directions) etc. While the character that moves flashes I don't think the gui flashes when it scrolls (scrolling has stopped working with the new version of autoit due to a small issue with the include files). You can make the bullets move faster (currently $bullet_speed=2) By the way I admit that I should have chosen a better background.yeh it works.. altough very buggy and strange..- (negative):1) I dont know what the point is, what do I have to do?2) you say it doesn't flash.. well at my computer it flashes!3) The gui is totally missplaced.. It is specially made for your computer...4) the bullet moves to slow5) the background is ugly..+ (positive):1) The jet and jump funtions work real smooth and cool.. IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now